# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
62350 | 2018-07-28T08:06:57 Z | win11905 | Pictionary (COCI18_pictionary) | C++11 | 614 ms | 14968 KB |
#include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define x first #define y second const int N = 1e5+5; int n, m, q; int L[N], R[N], X[N], Y[N], P[N]; vector<int> ls[N]; int find(int x) { return P[x] = P[x] == x ? x : find(P[x]); } int main() { scanf("%d %d %d", &n, &m, &q); for(int i = 0; i < q; ++i) scanf("%d %d", X+i, Y+i), L[i] = 1, R[i] = m; for(int it = 0; it < 18; ++it) { iota(P, P + N, 0); for(int i = 0; i < q; ++i) if(L[i] < R[i]) ls[L[i]+R[i] >> 1].emplace_back(i); for(int i = 1; i <= m; ++i) { int z = m - i + 1; for(int i = z + z; i <= n; i += z) { int u = find(z), v = find(i); if(u != v) P[u] = v; } for(auto now : ls[i]) { if(find(X[now]) == find(Y[now])) R[now] = i; else L[now] = i+1; } ls[i].clear(); } } for_each(R, R + q, [](int x) { printf("%d\n", x); }); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 3320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 4196 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 69 ms | 7356 KB | Output is correct |
2 | Correct | 49 ms | 7356 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 77 ms | 9000 KB | Output is correct |
2 | Correct | 63 ms | 9000 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 132 ms | 9000 KB | Output is correct |
2 | Correct | 112 ms | 9000 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 153 ms | 9000 KB | Output is correct |
2 | Correct | 189 ms | 9000 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 238 ms | 10364 KB | Output is correct |
2 | Correct | 212 ms | 10364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 240 ms | 10364 KB | Output is correct |
2 | Correct | 351 ms | 11292 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 394 ms | 13156 KB | Output is correct |
2 | Correct | 444 ms | 13156 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 614 ms | 14968 KB | Output is correct |
2 | Correct | 515 ms | 14968 KB | Output is correct |