Submission #709971

#TimeUsernameProblemLanguageResultExecution timeMemory
709971vjudge1Carnival (CEOI14_carnival)C++17
100 / 100
23 ms764 KiB
/* #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("unroll-loops") */ // lethal option #include<bits/stdc++.h> using namespace std; #define all(flg) flg.begin(), flg.end() #define int long long #define pb push_back #define fi first #define se second #define eb emplace_back #define ii pair<int, int> #define vi vector<int> #define PI 3.141592653589793238462643383279502884 #define ll long long #define ld long double #define for1(i, ff, gg) for(int i = ff; i <= gg; ++i) #define for2(i, ff, gg) for(int i = ff; i >= gg; --i) const ll mod = 1e9 + 7; const int maxN = 155; const ll oo = 1e18 + 7; int n, a[maxN]; int x, y, z, k; int ans[maxN]; int isdif(vi sus){ cout << sus.size() << endl; for(int cc : sus) cout << cc << " "; cout << endl; int x; cin >> x; return(x != sus.size()); } void sliced(vi &v, vi &v1, vi &v2){ v1.clear(); v2.clear(); for1(i, 0, (int)v.size() - 1){ if(i & 1) v1.pb(v[i]); else v2.pb(v[i]); } } vi cope(vi f1, vi f2){ for(int cc : f2) f1.pb(cc); return f1; } void solve(vi cac){ vi store = cac; if(!isdif(cac)){ x = 0; for(int cc : cac) ans[cc] = ++x; return; } vi f1, f2; while(1){ sliced(cac, f1, f2); if(isdif(f1)) cac = f1; else if(isdif(f2)) cac = f2; else break; } while(1){ if(f1.size() == 1) swap(f1, f2); if(f1.size() == 1) break; vi c1, c2; sliced(f1, c1, c2); if(isdif(cope(c1, f2))) f1 = c1; else f1 = c2; } ans[f1[0]] = -f2[0]; vi good; for(int cc : store) if(cc != f1[0]) good.pb(cc); solve(good); } signed main(){ // freopen(".inp", "r", stdin); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> n; vi cac; memset(ans, 0, sizeof(ans)); for1(i, 1, n) cac.pb(i); solve(cac); cout << 0 << endl; for1(i, 1, n){ for1(i, 1, n){ if(ans[i] < 0) ans[i] = ans[-ans[i]]; } } for1(i, 1, n) cout << ans[i] << " "; cout << endl; }

Compilation message (stderr)

carnival.cpp: In function 'long long int isdif(std::vector<long long int>)':
carnival.cpp:36:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     int x; cin >> x; return(x != sus.size());
      |                             ~~^~~~~~~~~~~~~
#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...