Submission #52197

#TimeUsernameProblemLanguageResultExecution timeMemory
52197zadrgaCarnival (CEOI14_carnival)C++14
100 / 100
10 ms580 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define INF (1LL << 55) #define maxn 155 typedef long long ll; typedef pair<int, int> pii; int val[maxn]; vector<int> v; int ask(int l, int d, int x){ vector<int> cur; for(int i = l; i <= d; i++) cur.pb(v[i]); cur.pb(x); cout << cur.size(); for(int i : cur) cout << " " << i; cout << endl; int ret; cin >> ret; return ret; } int main(){ int n, cnt = 0; scanf("%d", &n); for(int i = 1; i <= n; i++){ int num = ask(0, v.size() - 1, i); if(num == v.size() + 1){ v.pb(i); val[i] = ++cnt; continue; } int l = 0, d = v.size() - 1, mid; while(l <= d){ mid = (l + d) / 2; num = ask(l, mid, i); if(num == 1){ val[i] = val[v[l]]; break; } if(num == (mid - l + 1 + 1)) l = mid + 1; else d = mid; } } cout << "0"; for(int i = 1; i <= n; i++) cout << " " << val[i]; cout << endl; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:42:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(num == v.size() + 1){
      ~~~~^~~~~~~~~~~~~~~
carnival.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
#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...