Submission #383902

#TimeUsernameProblemLanguageResultExecution timeMemory
383902mohamedsobhi777Carnival (CEOI14_carnival)C++14
0 / 100
106 ms748 KiB
#include <bits/stdc++.h> using namespace std; #define vi vector<int> #define vll vector<ll> #define vii vector<pair<int, int>> #define pii pair<int, int> #define pll pair<ll, ll> #define loop(_) for (int __ = 0; __ < (_); ++__) #define pb push_back #define f first #define s second #define sz(_) ((int)_.size()) #define all(_) _.begin(), _.end() #define lb lower_bound #define ub upper_bound using ll = long long; using ld = long double; const int N = 1e5 + 7; const ll mod = 1e9 + 7; int n; struct dsu { int fat[N]; dsu() { iota(fat, fat + N, 0); } int find(int x) { return fat[x] = (x == fat[x] ? x : find(fat[x])); } void link(int u, int v) { u = find(u), v = find(v); if (u < v) swap(u, v); fat[u] = v; } bool same(int u, int v) { return find(u) == find(v); } } d; int ask(vi query) { cout << sz(query) << " "; for (auto u : query) cout << u << " "; cout << endl; cout << flush; int ret; cin >> ret; return ret; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifndef ONLINE_JUDGE // freopen("in.in", "r", stdin); #endif cin >> n; for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { if (ask({i, j}) == 1) { d.link(i, j); } } } cout << 0 << " "; for (int i = 1; i <= n; ++i) { cout << d.find(i) << " "; } cout << endl; cout << flush; return 0; }
#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...