제출 #623178

#제출 시각아이디문제언어결과실행 시간메모리
623178ollel최후의 만찬 (IOI12_supper)C++14
100 / 100
286 ms11156 KiB
using namespace std; #include <bits/stdc++.h> #include "advisor.h" typedef vector<int> vi; typedef vector<vi> vvi; typedef long long ll; typedef pair<int,int> pii; typedef vector<bool> vb; #define rep(i,a,b) for(int i = a; i < b; i++) #define pb push_back // // void WriteAdvice(int x) { // cout << x << " "; // } void ComputeAdvice(int *c, int n, int k, int m) { bool debug = false; int ans = 0; set<int> scaffold; rep(i,0,k) scaffold.insert(i); vi advice(2*n, 0); vi added(n, 0); rep(i,0,k) added[i] = i; vi nextOccurenceOfColor(n,1e9); vi sweep(n,1e9); for (int i = n - 1; i >= 0; i--) { nextOccurenceOfColor[i] = sweep[c[i]]; sweep[c[i]] = i; } priority_queue<pair<int,int>> pq; rep(i,0,k) pq.push({sweep[i], i}); if (debug) for (auto k : scaffold) cout << k << " "; cout << endl; rep(i,0,n) { int color = c[i]; added[color] = n+i; if (scaffold.find(color) != scaffold.end()) { if (debug) for (auto k : scaffold) cout << k << " "; cout << endl; pq.push({nextOccurenceOfColor[i], c[i]}); continue; } int toRemove = -1; while (scaffold.find(toRemove) == scaffold.end()) { assert(pq.size() != 0); pair<int,int> res = pq.top(); pq.pop(); if (debug) cout << "popped " << res.first << ", "<< res.second << endl; toRemove = res.second; } pq.push({nextOccurenceOfColor[i], c[i]}); advice[added[toRemove]] = 1; if (debug) cout << "advice at " << added[toRemove] << endl; scaffold.erase(toRemove); ans++; scaffold.insert(c[i]); if (debug) cout << "pushing " << c[i] << " with next occ " << nextOccurenceOfColor[i] << endl; if (debug) for (auto k : scaffold) cout << k << " "; cout << endl; } rep(i,0,2*n) WriteAdvice(advice[i]); if (debug) cout << "\nanswer: " << ans << endl; } // int main() { // int c[] ={4, 1, 2, 1, 2, 1, 4, 2}; // ComputeAdvice(c, 8, 2, -1); // }
using namespace std; #include <bits/stdc++.h> #include "assistant.h" typedef vector<int> vi; typedef vector<vi> vvi; typedef long long ll; typedef pair<int,int> pii; typedef vector<bool> vb; #define rep(i,a,b) for(int i = a; i < b; i++) #define pb push_back void Assist(unsigned char *a, int n, int k, int r) { set<int> scaffold; rep(i,0,k) scaffold.insert(i); vector<int> advice(2*n); rep(i,0,2*n) advice[i] = a[i]; queue<int> q; rep(i,0,k) if (advice[i] == 1) q.push(i); rep(i,0,n) { int nextColor = GetRequest(); if (scaffold.find(nextColor) == scaffold.end()) { int rem = q.front(); q.pop(); PutBack(rem); scaffold.erase(rem); scaffold.insert(nextColor); } if (advice[n + i] == 1) { q.push(nextColor); } } }

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

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:40:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   40 |   if (debug) for (auto k : scaffold) cout << k << " "; cout << endl;
      |   ^~
advisor.cpp:40:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   40 |   if (debug) for (auto k : scaffold) cout << k << " "; cout << endl;
      |                                                        ^~~~
advisor.cpp:47:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   47 |       if (debug) for (auto k : scaffold) cout << k << " "; cout << endl;
      |       ^~
advisor.cpp:47:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   47 |       if (debug) for (auto k : scaffold) cout << k << " "; cout << endl;
      |                                                            ^~~~
advisor.cpp:70:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   70 |     if (debug) for (auto k : scaffold) cout << k << " "; cout << endl;
      |     ^~
advisor.cpp:70:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   70 |     if (debug) for (auto k : scaffold) cout << k << " "; cout << endl;
      |                                                          ^~~~
#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...