Submission #1228619

#TimeUsernameProblemLanguageResultExecution timeMemory
1228619arkanefuryCarnival (CEOI14_carnival)C++20
0 / 100
29 ms7488 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define in insert #define lb lower_bound #define F first #define S second #define sz size() #define int long long #define all(v) v.begin(),v.end() #define FOR1(x, n) for(int j = x; j <= n; j ++) #define FOR(x, n, m, d) for(int x = n; x <= m; x += d) #define FORR(x, n, m, d) for(int x = n; x >= m; x -= d) #define nikita ios_base::sync_with_stdio(0), cin.tie(0); const int N = 3e5+5; int a[N], b[N], pref[N], d[N],ans, inf = 1e18, p[N]; int n,m,k,sum=0,x,y, r, cnt, l, mod = 1e9+7; vector<int>g[N]; int par(int x){ if(x==p[x])return x; return par(p[x]); } void unite(int x, int y){ x = par(x), y = par(y); if(x < y)p[x] = y; else p[y] = x; } void solve() { nikita cin >> n; vector<int>v; FOR(i, 1, n, 1)p[i] = i; v.pb(1); FOR(i, 2, n, 1){ l = 0, r = v.sz - 1; x = 0; while(l < r){ int md = (r-l) >> 1; cout << md + 2 << ' '; FOR(j, l, md+l, 1)cout << v[j] << ' '; cout << i << endl; cin >> y; if(y == md + 2)l += md + 1; else r -= md; } l ++; cout << "2 " << l << ' ' << i << endl; cin >> x; if(x == 2)v.pb(i); else unite(i, l); } k = 1; set<int>st; FOR(i, 1, n, 1)st.in(par(i)); for(auto i : st)b[i] = k, k ++; cout << "0 "; FOR(i, 1,n, 1)cout << b[par(i)] << ' '; return; } signed main(){ nikita int tt = 1; if(!tt)cin >> tt; FOR(i, 1, tt, 1)solve(); } /* dp[i][j] = min x, where last a[j] equal to x otherwise dp[i][j] = inf dp[1][1] = l[1]; for(i, 1, n, 1)dp[i][1] = l[i]; for(j, 1, n, 1)dp[i][j] = dp[i-1][j]; dp[i][j] <= dp[i][j+1] && dp[i][j] >= dp[i+1][j] for(j, 1, i-1, 1){ if(dp[i-1][j-1] <= r[i])dp[i][j] = min(dp[i][j], max(l[i], dp[i-1][j-1])) dp[i][j] = min(dp[i][j], dp[i-1][j-1]) } */
#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...