| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1239215 | Jer | Circle Passing (EGOI24_circlepassing) | C++20 | 3 ms | 580 KiB | 
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e9 + 5, MAXM = 5e5 + 5;
int n, m, q;
int k;
unordered_map<int, int> d;
int con[MAXM];
void find()
{
    set<int> vis;
    queue<int> q;
    q.push(0);
    int l = 0;
    while (!q.empty())
    {
        int len = q.size();
        for (int x = 0; x < len; x++)
        {
            int curr = q.front();
            q.pop();
            if (vis.find(curr) != vis.end())
                continue;
            vis.insert(curr);
            d[curr] = l;
            if (curr > 0)
                q.push(curr - 1);
            if (curr < 2 * n - 1)
                q.push(curr + 1);
            if (curr == 0)
                q.push(2 * n - 1);
            if (curr == 2 * n - 1)
                q.push(0);
            if (con[curr] != -1)
                q.push(con[curr]);
        }
        l++;
    }
}
int main()
{
    scanf("%d%d%d", &n, &m, &q);
    for (int i = 0; i < m; i++)
        scanf("%d", &k), con[k] = n + k, con[n + k] = k;
    find();
    int a, b;
    while (q--)
    {
        scanf("%d%d", &a, &b);
        printf("%d\n", d[b]);
    }
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
