Submission #623142

# Submission time Handle Problem Language Result Execution time Memory
623142 2022-08-05T08:58:08 Z ollel Last supper (IOI12_supper) C++14
0 / 100
2500 ms 4200 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;

  rep(i,0,n) {
    // for (auto k : scaffold) cout << k << " "; cout << endl;
    int color = c[i];
    if (scaffold.find(color) != scaffold.end()) {
      added[color] = n+i;
      continue;
    }

    set<int> passed;
    bool adviced = false;
    rep(j,i+1,n) {
      if (passed.size() == scaffold.size() - 1) {
        int res = 0;
        for (auto x : scaffold) if (passed.find(x) == passed.end()) res = x;
        advice[added[res]] = 1;
        // cout << "remove " << res << " at " << i << endl;

        scaffold.erase(res);
        adviced = true;
      }

      if (scaffold.find(c[j]) != scaffold.end()) passed.insert(c[j]);
    }
    if (!adviced) {
      int res = 0;
      for (auto x : scaffold) if (passed.find(x) == passed.end()) res = x;
      advice[added[res]] = 1;
      // cout << "remove " << res << " at " << i << endl;
      scaffold.erase(res);
    }

    scaffold.insert(c[i]);
  }
  rep(i,0,2*n) WriteAdvice(advice[i]);
}

// int main() {
//   int c[] ={0, 4, 5, 2, 1, 3};
//   ComputeAdvice(c, 6, 3, -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 516 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 Execution timed out 2566 ms 748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2585 ms 3028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 553 ms 836 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 Execution timed out 2554 ms 3412 KB Time limit exceeded
2 Execution timed out 2570 ms 3660 KB Time limit exceeded
3 Execution timed out 2569 ms 3796 KB Time limit exceeded
4 Execution timed out 2530 ms 3796 KB Time limit exceeded
5 Execution timed out 2568 ms 3668 KB Time limit exceeded
6 Execution timed out 2571 ms 3776 KB Time limit exceeded
7 Execution timed out 2569 ms 3792 KB Time limit exceeded
8 Execution timed out 2533 ms 3776 KB Time limit exceeded
9 Execution timed out 2577 ms 3796 KB Time limit exceeded
10 Execution timed out 2570 ms 4200 KB Time limit exceeded