Submission #574948

#TimeUsernameProblemLanguageResultExecution timeMemory
5749481zaid1Carnival (CEOI14_carnival)C++14
20 / 100
110 ms10704 KiB
#include <bits/stdc++.h> using namespace std; // #define endl '\n' const int M = 2e5+5, MOD = 1000000007; #define int long long int rnk[M], clr[M], p[M]; set<int> nono[M]; int find(int s) { return (s == p[s]?s:p[s]=find(p[s])); } void uni(int a, int b) { if (rnk[a] < rnk[b]) swap(a, b); if (rnk[a] == rnk[b]) rnk[a]++; p[b] = a; clr[a] = min(clr[a], clr[b]); } signed main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; for (int i = 1; i <= n; i++) clr[i] = p[i] = i; for (int i=1;i<=n;i++) { for(int j=i+1;j<=n;j++) { bool check = 1; for (int k:nono[j]) { if (find(i) == find(k)) check = 0; } for (int k:nono[i]) { if (find(j) == find(k)) check = 0; } if (find(i) != find(j) && check) { cout << 2 << ' ' << i << ' ' << j << endl; int x; cin >> x; if (x == 1) uni(find(i), find(j)); else { nono[find(i)].insert(find(j)); nono[find(j)].insert(find(i)); } } } } map<int, int> mp; set<int> st; for (int i = 1; i <= n; i++) st.insert(find(i)); int cnt = 1; for (int i:st) mp[i] = cnt++; cout << 0 << ' '; for (int i = 1; i <= n; i++) cout << mp[clr[find(i)]] << ' '; cout << endl; return 0; } /* 3 0 3 0 3 0 0 5 4 0 3 1 1 1 3 0 1 4 5 1 */

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:61:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   61 |     for (int i = 1; i <= n; i++) cout << mp[clr[find(i)]] << ' '; cout << endl;
      |     ^~~
carnival.cpp:61:67: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   61 |     for (int i = 1; i <= n; i++) cout << mp[clr[find(i)]] << ' '; cout << endl;
      |                                                                   ^~~~
#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...