Submission #125061

# Submission time Handle Problem Language Result Execution time Memory
125061 2019-07-04T14:06:49 Z RockyB Last supper (IOI12_supper) C++17
8 / 100
2500 ms 18224 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(dp) && 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 : in) {
      if (it == 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 10024 KB Output is correct
2 Correct 8 ms 10224 KB Output is correct
3 Correct 9 ms 10312 KB Output is correct
4 Correct 13 ms 10480 KB Output is correct
5 Correct 15 ms 10480 KB Output is correct
6 Correct 24 ms 10576 KB Output is correct
7 Correct 15 ms 10992 KB Output is correct
8 Correct 83 ms 10992 KB Output is correct
9 Correct 59 ms 10960 KB Output is correct
10 Correct 81 ms 10992 KB Output is correct
11 Correct 58 ms 10792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 187 ms 11608 KB Output is correct
2 Correct 1779 ms 18224 KB Output is correct
3 Execution timed out 2551 ms 12680 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2558 ms 10556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 10480 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2556 ms 11460 KB Time limit exceeded
2 Execution timed out 2555 ms 11536 KB Time limit exceeded
3 Execution timed out 2573 ms 11916 KB Time limit exceeded
4 Execution timed out 2556 ms 11896 KB Time limit exceeded
5 Execution timed out 2548 ms 12008 KB Time limit exceeded
6 Execution timed out 2545 ms 11800 KB Time limit exceeded
7 Execution timed out 2567 ms 11712 KB Time limit exceeded
8 Execution timed out 2537 ms 11760 KB Time limit exceeded
9 Execution timed out 2555 ms 11812 KB Time limit exceeded
10 Execution timed out 2540 ms 11740 KB Time limit exceeded