Submission #1303769

#TimeUsernameProblemLanguageResultExecution timeMemory
1303769nicolo_010Last supper (IOI12_supper)C++20
0 / 100
233 ms8812 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#include "advisor.h"

void ComputeAdvice(int *c, int n, int k, int m) {
  for (int i=0; i<n; i++) {
    for (int b=0; b<17; b++) {
      if (c[i]&(1<<b)) WriteAdvice(1);
      else WriteAdvice(0);
    }
  }
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#include "assistant.h"

void Assist(unsigned char *a, int n, int k, int r) {
  int c[n];
  for (int i=0; i<n; i++) {
    int num=0;
    for (int j=17*i; j<17*(i+1); j++) {
      int bit = a[j];
      num += bit*(1<<(j%17));
    }
    c[i] = num;
  }
  set<int> s;
  for (int i=0; i<n; i++) {
    s.insert(c[i]);
  }
  vector<int> last(n, -1);
  for (int i=0; i<n; i++) {
    last[c[i]] = i;
  }
  set<pii, greater<pii>> need;
  set<int> notneed;
  for (int i=0; i<k; i++) {
    if (s.count(i)) need.insert({{last[i], i}});
    else notneed.insert(i);
  }


  for (int i=0; i<n; i++) {
    int col = GetRequest();
    if (need.count({last[col], col})) {
      if (last[col] <= i) {
        notneed.insert(col);
      }   
      continue;   
    }
    if (notneed.size() >= 1) {
      auto it = notneed.begin();
      PutBack(*it);
      notneed.erase(it);
      if (last[col] <= i) notneed.insert(col);
      else need.insert({last[col], col});
    }
    else {
      auto it = need.begin();
      PutBack(it->second);
      need.erase(it);
      if (last[col] <= i) notneed.insert(col);
      else need.insert({last[col], col});
    }
  }
}
#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...