Submission #829935

#TimeUsernameProblemLanguageResultExecution timeMemory
829935BlagojLast supper (IOI12_supper)C++17
0 / 100
328 ms19524 KiB
#include <bits/stdc++.h> #include "advisor.h" using namespace std; void ComputeAdvice(int *C, int N, int K, int M) { queue<int> toDelete; unordered_map<int, int> cnt; set<int> s[N + 2]; int Last[N + 2]; for (int i = 0; i < N; i++) { cnt[C[i]]++; s[C[i]].insert(i + K); } for (int i = 0; i < K; i++) { Last[i] = i; if (!cnt[i]) toDelete.push(i); } vector<int> op(N + K); unordered_set<int> have; for (int i = 0; i < K; i++) { have.insert(i); if (!cnt[i]) op[i] = 1; } for (int i = 0; i < N; i++) { Last[C[i]] = i + K; if (have.count(C[i])) { cnt[C[i]]--; if (!cnt[C[i]]) { toDelete.push(C[i]); op[i + K] = 1; } } else { if (toDelete.size() == 0) { int last, position = -1; for (int x : have) { int temp = *s[x].lower_bound(i); if (temp > position) { position = temp; last = x; } } toDelete.push(last); op[Last[last]] = 1; } int fr = toDelete.front(); toDelete.pop(); have.erase(fr); have.insert(C[i]); cnt[C[i]]--; if (!cnt[C[i]]) { toDelete.push(C[i]); op[i + K] = 1; } } } for (int i = 0; i < op.size(); i++) { WriteAdvice(op[i]); } }
#include <bits/stdc++.h> #include "assistant.h" using namespace std; void Assist(unsigned char *A, int N, int K, int R) { queue<int> toDelete; unordered_set<int> have; for (int i = 0; i < K; i++) { if (A[i] == 1) toDelete.push(i); have.insert(i); } for (int i = 0; i < N; i++) { int req = GetRequest(); if (!have.count(req)) { PutBack(toDelete.front()); have.erase(toDelete.front()); toDelete.pop(); have.insert(req); } if (A[i + K] == '1') { toDelete.push(req); } } }

Compilation message (stderr)

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:58:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |  for (int i = 0; i < op.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...