# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
62345 | 2018-07-28T07:54:34 Z | win11905 | Pictionary (COCI18_pictionary) | C++11 | 894 ms | 17968 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]; 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; bool status = true; while(status) { status = false; iota(P, P + N, 0); priority_queue<pii, vector<pii>, greater<pii> > Q; for(int i = 0; i < q; ++i) if(L[i] < R[i]) Q.emplace(L[i]+R[i] >> 1, i), status = true; 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; } while(!Q.empty() && Q.top().x == i) { auto now = Q.top(); Q.pop(); if(find(X[now.y]) == find(Y[now.y])) R[now.y] = i; else L[now.y] = i+1; } } } for_each(R, R + q, [](int x) { printf("%d\n", x); }); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 1768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 148 ms | 4396 KB | Output is correct |
2 | Correct | 120 ms | 5060 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 206 ms | 6756 KB | Output is correct |
2 | Correct | 159 ms | 7216 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 237 ms | 7216 KB | Output is correct |
2 | Correct | 275 ms | 7216 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 283 ms | 7356 KB | Output is correct |
2 | Correct | 219 ms | 8056 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 486 ms | 9856 KB | Output is correct |
2 | Correct | 328 ms | 9856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 334 ms | 11852 KB | Output is correct |
2 | Correct | 617 ms | 12616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 775 ms | 14200 KB | Output is correct |
2 | Correct | 838 ms | 15268 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 842 ms | 16780 KB | Output is correct |
2 | Correct | 894 ms | 17968 KB | Output is correct |