Submission #738437

#TimeUsernameProblemLanguageResultExecution timeMemory
738437LucaGregCarnival (CEOI14_carnival)C++17
100 / 100
27 ms280 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second //#define int long long int const int INF = 2000000000000000; const int mod = 1000000007; int marc[160]; int n; int bb(int id, int ini, int fim){ vector<int> query; for(int i=ini;i<=fim;i++) if(marc[i]==0) query.pb(i); if(query.empty()) return -1; cout<<query.size()<<" "; for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" "; cout<<"\n"; cout.flush(); int qtd; cin>>qtd; query.pb(id); cout<<query.size()<<" "; for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" "; cout<<"\n"; cout.flush(); int qtdId; cin>>qtdId; if(qtdId>qtd) return -1; while(ini<fim){ query.clear(); int m = (ini + fim)/2; for(int i=ini;i<=m;i++) if(marc[i]==0) query.pb(i); if(query.empty()){ ini = m + 1; continue; } int auxQtd; if((int)query.size()>1){ cout<<query.size()<<" "; for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" "; cout<<"\n"; cout.flush(); cin>>auxQtd; }else{ auxQtd = 1; } query.pb(id); cout<<query.size()<<" "; for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" "; cout<<"\n"; cout.flush(); int auxQtdId; cin>>auxQtdId; if(auxQtdId>auxQtd) ini = m + 1; else fim = m; } return fim; } main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); cin>>n; int curType = 1; for(int i=1;i<=n;i++){ if(marc[i]!=0) continue; marc[i] = curType; while(true){ int id = bb(i, i + 1, n); if(id==-1) break; marc[id] = curType; } curType++; } cout<<0<<" "; for(int i=1;i<=n;i++) cout<<marc[i]<<" "; cout<<"\n"; return 0; }

Compilation message (stderr)

carnival.cpp:11:17: warning: overflow in conversion from 'long int' to 'int' changes value from '2000000000000000' to '1233977344' [-Woverflow]
   11 | const int INF = 2000000000000000;
      |                 ^~~~~~~~~~~~~~~~
carnival.cpp:63:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   63 | main()
      | ^~~~
#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...