Submission #176070

#TimeUsernameProblemLanguageResultExecution timeMemory
176070mat_vCarnival (CEOI14_carnival)C++14
100 / 100
30 ms380 KiB
#include <bits/stdc++.h> #define mod 1000000007 #define pb push_back #define mid(l, r) ((l)+(r))/2 #define len(a) (a).length() #define sz(a) (a).size() #define xx first #define yy second #define inf int(2e9) #define ff(i, a, b) for(int (i) = (a); (i) <= (b); ++(i)) #define fb(i, a, b) for(int (i) = (a); (i) >= (b); --(i)) using namespace std; typedef long long ll; typedef pair<int,int> pii; template<class T> void print(const T niz[], const int siz) { for(int i=0;i<siz;i++) cout << niz[i] << " "; cout << endl; } int n; vector<int>upit; int pitaj(int l, int r){ upit.clear(); ff(i,l,r)upit.pb(i); cout << upit.size() << " "; for(auto c:upit)cout << c << " "; cout << endl; int odg; cin >> odg; cout << endl; return odg; } bool znam[200]; int niz[200]; int nadjisl(int x){ if(x == n)return n + 1; int l = 1; int r = n - x; int p = pitaj(x, n); int p2 = pitaj(x + 1, n); if(p > p2)return n + 1; while(l < r){ int mid = (l + r) / 2; int sta = pitaj(x, x + mid); int sta2 = pitaj(x + 1, x + mid); if(sta > sta2){ l = mid + 1; } else r = mid; } return x+l; } int main() { ios_base::sync_with_stdio(false); int br = 1; cin >> n; ff(i,1,n){ if(znam[i])continue; niz[i] = br; znam[i] = 1; int tr = i; while(1){ tr = nadjisl(tr); znam[tr] = 1; niz[tr] = br; if(tr > n)break; } br++; } cout << 0 << " "; ff(i,1,n)cout << niz[i] << " "; cout << endl; 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...