Submission #125058

# Submission time Handle Problem Language Result Execution time Memory
125058 2019-07-04T14:04:37 Z RockyB Last supper (IOI12_supper) C++17
0 / 100
2500 ms 11924 KB
#include "advisor.h"
#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back

#define sz(x) (int)x.size()

#define rep(z, a, b) for (int z = (a); (z) <= (b); z++)
#define per(z, a, b) for (int z = (a); (z) >= (b); z--)

using namespace std;

const int MAXN = (int)2e5 + 7;


vector <int> nxt[MAXN];
set <int> in;
set < pair <int, int > > dp;
void ComputeAdvice(int *C, int N, int K, int M) {
  rep(i, 0, N - 1) {
    nxt[i].pb(N);
  }
  per(i, N - 1, 0) {
    nxt[C[i]].pb(i);
  }
  rep(i, 0, K - 1) {
    in.insert(i);
    dp.insert({nxt[i].back(), i});
  }
  int LOG = log2(K);
  rep(i, 0, N - 1) {
    if (in.count(C[i])) {
      WriteAdvice(0);
      continue;
    }

    while (sz(in) && dp.begin() -> f <= i) {
      int x = dp.begin() -> s;
      dp.erase(dp.begin());
      nxt[x].pp();
      dp.insert({nxt[x].back(), x});
    }

    int del = dp.rbegin() -> s, id = 0;
    WriteAdvice(1);
    for (auto it : dp) {
      if (it.s == del) {
        break;
      }
      ++id;
    }

    dp.erase(--dp.end());
    in.erase(del);
    in.insert(C[i]);
    dp.insert({nxt[C[i]].back(), C[i]});
    // cerr << "PUT -> " << del << endl;
    rep(j, 0, LOG) {
      if (id & (1 << j)) WriteAdvice(1);
      else WriteAdvice(0);
    }
  }
} 
#include "assistant.h"
#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back

#define sz(x) (int)x.size()

#define rep(z, a, b) for (int z = (a); (z) <= (b); z++)
#define per(z, a, b) for (int z = (a); (z) >= (b); z--)

using namespace std;

const int MAXN = (int)2e5 + 7;

void Assist(unsigned char *A, int N, int K, int R) {
  int LOG = log2(K);
  set <int> st;
  rep(i, 0, K - 1) st.insert(i);
  for (int i = 0; i < R; ) {
    int add = GetRequest();
    if (A[i] == 0) {
      i++;
      continue;
    }
    else {
      i++;
      int id = 0;
      rep(j, 0, LOG) {
        if (A[i + j] == 1) id |= 1 << j;
      }
      int val = -1;
      for (auto it : st) {
        if (!id) {
          val = it;
          break;
        }
        --id;
      }
      i += LOG + 1;
      // cerr << val << " -> " << endl;
      PutBack(val);
      st.erase(val);
    }
    st.insert(add);
  }
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9968 KB Output is correct
2 Incorrect 8 ms 9968 KB Error - Not putting back color when it is not on the scaffold
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 158 ms 11688 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2513 ms 10500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 10480 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2536 ms 11428 KB Time limit exceeded
2 Execution timed out 2543 ms 11592 KB Time limit exceeded
3 Execution timed out 2555 ms 11896 KB Time limit exceeded
4 Execution timed out 2566 ms 11924 KB Time limit exceeded
5 Execution timed out 2563 ms 11904 KB Time limit exceeded
6 Execution timed out 2544 ms 11772 KB Time limit exceeded
7 Execution timed out 2547 ms 11896 KB Time limit exceeded
8 Execution timed out 2547 ms 11896 KB Time limit exceeded
9 Execution timed out 2542 ms 11920 KB Time limit exceeded
10 Execution timed out 2552 ms 11780 KB Time limit exceeded