Submission #272337

# Submission time Handle Problem Language Result Execution time Memory
272337 2020-08-18T11:26:54 Z sjimed Last supper (IOI12_supper) C++14
0 / 100
230 ms 141808 KB
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;

static queue<int> q[100010];
static set<pii> s;
static bool ans[200010];

void ComputeAdvice(int *C, int N, int K, int M) {
  
  for(int i=0; i<N; i++) {
    q[C[i]].em(i);
  }

  for(int i=0; i<N; i++)
    q[i].em(N);

  for(int i=0; i<K; i++) {
    s.insert(mp(q[i].front(), i - K));
  }

  for(int i=0; i<N; i++) {
    if(s.begin()->fi == i) {
      s.erase(s.begin());
      
      q[C[i]].pop();
      s.insert(mp(q[C[i]].front(), i));
    }
    else {
      int x = prev(s.end())->se;
      ans[x + K] = true;

      s.erase(prev(s.end()));

      q[C[i]].pop();
      s.insert(mp(q[C[i]].front(), i));
    }
  }

  for(int i=0; i<N+K; i++) {
    WriteAdvice(ans[i]);
  }
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;

static int n;
static set<int> t;
static vector<int> v[100010], s;

void Assist(unsigned char *A, int N, int K, int R) {
  n = N;

  for(int i=0; i<K; i++) {
    if(A[i]) s.eb(i);

    v[i].eb(i);
  }

  for(int i = K; i < N + K; i++) {
    int x = GetRequest();

    if(A[i]) s.eb(i);

    if(v[x].size() && !A[v[x].back()]) {
      v[x].eb(i);
      continue;
    }

    int y = s.back();
    PutBack(y);

    v[x].eb(i);
  }
}
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 135152 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 64 ms 135920 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 166 ms 140568 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 60 ms 135664 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 193 ms 141040 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 213 ms 141656 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 195 ms 141552 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 199 ms 141808 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 198 ms 141680 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 205 ms 141552 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 192 ms 141552 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 206 ms 141552 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 230 ms 141768 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 198 ms 141648 KB Error - Putting back a color that is not on the scaffold