Submission #130361

#TimeUsernameProblemLanguageResultExecution timeMemory
130361redaPictionary (COCI18_pictionary)C++14
42 / 140
1562 ms1528 KiB
#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 (stderr)

pictionary.cpp: In function 'int main()':
pictionary.cpp:52:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
                 if(Find(j)!=Find(i*j))
                 ^~
pictionary.cpp:54:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if(Find(a)==Find(b))
    ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...