H. Hints of sd0061

Codeforces
IDCF10225H
Time3000ms
Memory128MB
Difficulty
English · Original
Formal · Original
_sd0061_, a legend from Beihang University ACM-ICPC Team, retired last year leaving a group of noobs with no idea how to cope with $m$ upcoming contests. What _sd0061_ left for them is only a set of hints. There are $n$ noobs in the team, the $i$-th of which has a rating, $a_i$. _sd0061_ prepared one hint for each contest. The hint for the $j$-th contest is a number, $b_j$, which means that the noob with the $(b_j + 1)$-th lowest rating is ordained by _sd0061_ to compete in the $j$-th contest. The coach is going to ask _constroy_ to list these contestants. Before that, _constroy_ peeked these hints and found that $b_i + b_j <= b_k$ if $b_i eq.not b_j$, $b_i < b_k$, $b_j < b_k$. Now, you are in charge of making the list for _constroy_. The input contains multiple (about $15$) test cases. For each test case, the first line contains five integers $n$, $m$, $A$, $B$, $C$ ($1 <= n <= 10^7$, $1 <= m <= 100$, $0 <= A, B, C < 2^(32)$). The second line contains $m$ integers, the $i$-th number of which is $b_i$ ($0 <= b_i < n$). Ratings of these $n$ noobs are obtained by calling the following C/C++ function $n$ times, the $i$-th result of which is $a_i$. In this function, _unsigned_ means the unsigned $32$-bit integer type, and _^_ means the bitwise XOR operator. Note any integer overflow may occur in the function should be ignored, and $x$, $y$, $z$ are reset to their initial values $A$, $B$, $C$ respectively at the beginning of each test case. For each test case, output "_Case #x: y$""_1$ y$""_2$ $\\dots$ y$""_m$_" in one line (without quotes), where $x$ indicates the case number starting from $1$, and $y_i$ denotes the rating of the noob ordained for the $i$-th contest in the corresponding case. ## Input The input contains multiple (about $15$) test cases.For each test case, the first line contains five integers $n$, $m$, $A$, $B$, $C$ ($1 <= n <= 10^7$, $1 <= m <= 100$, $0 <= A, B, C < 2^(32)$).The second line contains $m$ integers, the $i$-th number of which is $b_i$ ($0 <= b_i < n$).Ratings of these $n$ noobs are obtained by calling the following C/C++ function $n$ times, the $i$-th result of which is $a_i$.unsigned x = A, y = B, z = C;unsigned rng61() { unsigned t; x = x ^ (x << 16); x = x ^ (x >> 5); x = x ^ (x << 1); t = x; x = y; y = z; z = (t ^ x) ^ y; return z;}In this function, _unsigned_ means the unsigned $32$-bit integer type, and _^_ means the bitwise XOR operator. Note any integer overflow may occur in the function should be ignored, and $x$, $y$, $z$ are reset to their initial values $A$, $B$, $C$ respectively at the beginning of each test case. ## Output For each test case, output "_Case #x: y$""_1$ y$""_2$ $\\dots$ y$""_m$_" in one line (without quotes), where $x$ indicates the case number starting from $1$, and $y_i$ denotes the rating of the noob ordained for the $i$-th contest in the corresponding case. [samples]
**Definitions** Let $ q \in \mathbb{Z} $ be the number of queries. For each $ i \in \{1, \dots, q\} $, let $ n_i, m_i \in \mathbb{Z} $ be integers such that $ 1 \leq n_i < m_i \leq 10^6 $. **Constraints** 1. $ 1 \leq q \leq 10^5 $ 2. For each $ i $, $ 1 \leq n_i < m_i \leq 10^6 $ **Objective** For each query $ (n_i, m_i) $, find the smallest positive integer $ x_i $ such that: $$ n_i^{x_i} \equiv 1 \pmod{m_i} $$ If no such $ x_i $ exists, output $ -1 $. (If multiple $ x_i $ exist, output any satisfying $ 0 \leq x_i \leq 10^6 $.) Note: $ x_i $ is the order of $ n_i $ modulo $ m_i $, if it exists.
API Response (JSON)
{
  "problem": {
    "name": "H. Hints of sd0061",
    "description": {
      "content": "_sd0061_, a legend from Beihang University ACM-ICPC Team, retired last year leaving a group of noobs with no idea how to cope with $m$ upcoming contests. What _sd0061_ left for them is only a set of h",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 131072
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10225H"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "_sd0061_, a legend from Beihang University ACM-ICPC Team, retired last year leaving a group of noobs with no idea how to cope with $m$ upcoming contests. What _sd0061_ left for them is only a set of h...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ q \\in \\mathbb{Z} $ be the number of queries.  \nFor each $ i \\in \\{1, \\dots, q\\} $, let $ n_i, m_i \\in \\mathbb{Z} $ be integers such that $ 1 \\leq n_i < m_i \\leq 10^6 $.\n\n**Cons...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments