[CCC 2021 S5] Math Homework

Luogu
IDLGP9027
Time500ms
Memory128MB
DifficultyP4
线段树2021Special JudgeCCC(加拿大)ST 表构造差分
构造一个长度为 $N$ 的整数序列 $A$,使得: 1. $\forall i=1,2,\cdots,N,1\leq A_i\leq 10^9$; 2. $\forall i=1,2,\cdots,M,\gcd(A_{X_i},A_{X_i+1},\cdots,A_{Y_i})=Z_i$。 或者报告无解。 ## Input 第一行,$N,M$。 接下来 $M$ 行,每行有 $X_i,Y_i,Z_i$,描述一个限制 2. ## Output 一行,序列 $A$,或者 `Impossible`。 [samples] ## Note $$1\leq N\leq 150000,1\leq M\leq 150000,1\leq Z_i\leq 16$$ 译自 [CCC2021 S5](https://cemc.math.uwaterloo.ca/contests/computing/past_ccc_contests/2021/ccc/seniorEF.pdf)。 spj 在附件里,发现锅了请联系[我](/user/90693)。
Samples
Input #1
2 2
1 2 2
2 2 6
Output #1
4 6
Input #2
2 2
1 2 2
2 2 5
Output #2
Impossible
API Response (JSON)
{
  "problem": {
    "name": "[CCC 2021 S5]  Math Homework",
    "description": {
      "content": "构造一个长度为 $N$ 的整数序列 $A$,使得: 1. $\\forall i=1,2,\\cdots,N,1\\leq A_i\\leq 10^9$; 2. $\\forall i=1,2,\\cdots,M,\\gcd(A_{X_i},A_{X_i+1},\\cdots,A_{Y_i})=Z_i$。 或者报告无解。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 500,
      "memory_limit": 131072
    },
    "difficulty": {
      "LuoguStyle": "P4"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP9027"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "构造一个长度为 $N$ 的整数序列 $A$,使得:\n\n1. $\\forall i=1,2,\\cdots,N,1\\leq A_i\\leq 10^9$;\n2. $\\forall i=1,2,\\cdots,M,\\gcd(A_{X_i},A_{X_i+1},\\cdots,A_{Y_i})=Z_i$。\n\n或者报告无解。\n\n## Input\n\n第一行,$N,M$。\n\n接下来 $M$ 行,每行有 $X_i,Y_...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments