Submission #623157

# Submission time Handle Problem Language Result Execution time Memory
623157 2022-08-05T09:19:04 Z ollel Last supper (IOI12_supper) C++14
0 / 100
137 ms 8308 KB
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) {
  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});

  // 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()) {
      continue;
    }

    pair<int,int> res = pq.top(); pq.pop();
    // cout << "popped " << res.first << ", "<< res.second << endl;
    int toRemove = res.second;
    advice[added[toRemove]] = 1;
    // cout << "advice at " << added[toRemove] << endl;
    scaffold.erase(toRemove);

    scaffold.insert(c[i]);
    pq.push({-nextOccurenceOfColor[i], c[i]});
    // for (auto k : scaffold) cout << k << " "; cout << endl;

  }
  rep(i,0,2*n) WriteAdvice(advice[i]);
}
// 
// int main() {
//   int c[] ={0, 1, 2, 1, 2, 1, 0, 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);
    }
  }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 508 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1436 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 6740 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 948 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 127 ms 7776 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 111 ms 7912 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 137 ms 8188 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 118 ms 8200 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 119 ms 8248 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 123 ms 8240 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 127 ms 8288 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 117 ms 8188 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 122 ms 8228 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 131 ms 8308 KB Error - Putting back a color that is not on the scaffold