# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
130361 | 2019-07-15T00:16:52 Z | reda | Pictionary (COCI18_pictionary) | C++14 | 1500 ms | 1528 KB |
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #define endl '\n' #define MAXN 1005 using namespace std; int Arr[MAXN]; int Arr2[MAXN]; int n; void init() { for(int i=1;i<=n;i++) { Arr[i] = i; Arr2[i] = 0; } } int Find(int x) { while(Arr[x] != x) { Arr[x]=Arr[Arr[x]] ; x=Arr[x]; } return x; } void Union (int a, int b) { a = Find(a); b = Find(b); if(Arr2[a] == Arr2[b]) Arr2[b]++; else if(Arr2[a] > Arr2[b]) swap(a, b); Arr[a] = b; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int q , m ; cin>>n>>m>>q; while(q--) { int a, b; cin>>a>>b; init(); int j; for(j=m;j>=1;j--) { for(int i=2;i*j<=n;i++) if(Find(j)!=Find(i*j)) Union(j, i*j); if(Find(a)==Find(b)) break; } cout<<m-j+1<<endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 166 ms | 636 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1067 ms | 1460 KB | Output is correct |
2 | Correct | 853 ms | 1528 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1562 ms | 1496 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 508 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |