Submission #1010151

#TimeUsernameProblemLanguageResultExecution timeMemory
1010151giorgi123glmCarnival (CEOI14_carnival)C++17
100 / 100
12 ms344 KiB
#include <iostream> #include <vector> #include <algorithm> #include <queue> using namespace std; using std::cout; using std::cin; vector <int> dsu_arr; const int dsu_parent (int p) { return (dsu_arr[p] == p ? p : dsu_arr[p] = dsu_parent (dsu_arr[p])); } inline void dsu_join (int a, int b) { a = dsu_parent (a), b = dsu_parent (b); if (a != b) dsu_arr[b] = a; } inline const bool check (int I, int L, int R) { if (L == R) { cout << 2 << ' ' << I << ' ' << L << '\n'; cout.flush (); int out = 0; cin >> out; if (out == 1) return 1; return 0; } cout << R - L + 1 << ' '; for (int i = L; i <= R; i++) cout << i << ' '; cout << '\n'; cout.flush(); int out1 = 0; cin >> out1; cout << R - L + 2 << ' '; for (int i = L; i <= R; i++) cout << i << ' '; cout << I << '\n'; cout.flush(); int out2 = 0; cin >> out2; if (out1 == out2) return true; return false; } int main () { int n = 0; cin >> n; dsu_arr.resize (n + 1); for (int i = 1; i <= n; i++) dsu_arr[i] = i; for (int i = 1; i <= n; i++) { int L = i + 1, R = n; int ans = -1; while (L <= R) { int mid = (L + R) / 2; if (check (i, L, mid)) { R = mid - 1; ans = mid; } else L = mid + 1; } // cout << '\t' << i << ' ' << ans << '\n'; if (ans != -1) dsu_join (i, ans); } cout << 0 << ' '; int free = 1; vector <int> v (n + 1, -1); for (int i = 1; i <= n; i++) { if (v[dsu_parent (i)] == -1) v[dsu_parent (i)] = free, free++; cout << v[dsu_parent (i)] << ' '; } cout.flush(); }
#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...