제출 #67321

#제출 시각아이디문제언어결과실행 시간메모리
67321Mamnoon_Siam사육제 (CEOI14_carnival)C++17
100 / 100
37 ms572 KiB
// #define local #include <bits/stdc++.h> using namespace std; int n; #ifdef local int wot[1 << 8]; int ask_local(vector<int> &vec) { set<int> st; for(int b : vec) { st.insert(wot[b]); } return st.size(); } #endif int ask(vector<int> &vec) { #ifdef local return ask_local(vec); #endif #ifndef local cout << vec.size() << ' '; for(int b : vec) cout << b + 1 << ' '; cout << endl; int ret; cin >> ret; return ret; #endif } int askn() { #ifdef local return n; #endif #ifndef local int ret; cin >> ret; return ret; #endif } void printsoln(vector<int> &ans) { cout << "0 "; for(int b : ans) cout << b + 1 << ' '; cout << endl; } int32_t main() { #ifdef local freopen("in", "r", stdin); cin >> n; for(int i = 0; i < n; i++) cin >> wot[i]; #endif n = askn(); vector<vector<int>> g(n); for(int i = 0; i < g.size(); i++) g[i].emplace_back(i); while(true) { { vector<int> ls; for(int i = 0; i < g.size(); i++) { ls.insert(ls.end(), g[i].begin(), g[i].end()); } if(ask(ls) == g.size()) { break; } } int L = -1, R = -1, lo, hi, mid; lo = 0, hi = g.size() - 1; while(lo <= hi) { mid = lo + hi >> 1; vector<int> ls; for(int i = 0; i <= mid; i++) { ls.insert(ls.end(), g[i].begin(), g[i].end()); } if(ask(ls) < mid + 1) { R = mid; hi = mid - 1; } else { lo = mid + 1; } } lo = 0, hi = R; while(lo <= hi) { mid = lo + hi >> 1; vector<int> ls; for(int i = mid; i <= R; i++) { ls.insert(ls.end(), g[i].begin(), g[i].end()); } if(ask(ls) < R - mid + 1) { L = mid; lo = mid + 1; } else { hi = mid - 1; } } g[L].insert(g[L].end(), g[R].begin(), g[R].end()); g.erase(g.begin() + R); } vector<int> ans(n); for(int i = 0; i < g.size(); i++) { for(int b : g[i]) { ans[b] = i; } } printsoln(ans); }

컴파일 시 표준 에러 (stderr) 메시지

carnival.cpp: In function 'int ask(std::vector<int>&)':
carnival.cpp:24:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int b : vec) cout << b + 1 << ' '; cout << endl;
  ^~~
carnival.cpp:24:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int b : vec) cout << b + 1 << ' '; cout << endl;
                                         ^~~~
carnival.cpp: In function 'void printsoln(std::vector<int>&)':
carnival.cpp:39:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int b : ans) cout << b + 1 << ' '; cout << endl;
  ^~~
carnival.cpp:39:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int b : ans) cout << b + 1 << ' '; cout << endl;
                                         ^~~~
carnival.cpp: In function 'int32_t main()':
carnival.cpp:52:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < g.size(); i++)
                 ~~^~~~~~~~~~
carnival.cpp:58:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i = 0; i < g.size(); i++) {
                   ~~^~~~~~~~~~
carnival.cpp:61:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(ask(ls) == g.size()) {
       ~~~~~~~~^~~~~~~~~~~
carnival.cpp:69:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    mid = lo + hi >> 1;
          ~~~^~~~
carnival.cpp:84:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    mid = lo + hi >> 1;
          ~~~^~~~
carnival.cpp:101:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < g.size(); i++) {
                 ~~^~~~~~~~~~
#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...