Submission #230238

#TimeUsernameProblemLanguageResultExecution timeMemory
230238syy사육제 (CEOI14_carnival)C++17
100 / 100
14 ms384 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++) #define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--) typedef pair<int, int> pi; #define f first #define s second #define pb push_back #define all(v) v.begin(), v.end() #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) int n, c, col[155], r; vector<int> v; int query(int x, int y, int z = 0) { cout << y-x+1+(z != 0)<< " "; while (x <= y) cout << v[x++] << " "; if (z) cout << z; cout << "\n"; cout.flush(); int res; cin >> res; return res; } int main() { fastio; cin >> n; FOR(i, 1, n) { v.pb(i); if (v.size() != query(0, v.size()-1)) v.pop_back(); } c = v.size(); FOR(i, 0, c-1) col[v[i]] = i+1; FOR(i, 1, n) if (!col[i]) { int lower = 0, upper = c-1; while (upper - lower > 1) { int mid = (upper + lower)/2; if (query(lower, mid, i) != mid-lower+2) upper = mid; else lower = mid+1; } cout << "2 " << v[lower] << " " << i << "\n"; cout.flush(); cin >> r; if (r == 1) col[i] = col[v[lower]]; else col[i] = col[v[upper]]; } FOR(i, 0, n) cout << col[i] << " "; cout << "\n"; cout.flush(); return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int query(int, int, int)':
carnival.cpp:20:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if (z) cout << z; cout << "\n";
  ^~
carnival.cpp:20:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if (z) cout << z; cout << "\n";
                    ^~~~
carnival.cpp: In function 'int main()':
carnival.cpp:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (v.size() != query(0, v.size()-1)) v.pop_back();
       ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:5:22: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 #define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
                      ^
carnival.cpp:44:2: note: in expansion of macro 'FOR'
  FOR(i, 0, n) cout << col[i] << " "; cout << "\n"; cout.flush();
  ^~~
carnival.cpp:44:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  FOR(i, 0, n) cout << col[i] << " "; cout << "\n"; cout.flush();
                                      ^~~~
#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...