Submission #126772

# Submission time Handle Problem Language Result Execution time Memory
126772 2019-07-08T11:46:58 Z RockyB Last supper (IOI12_supper) C++17
29 / 100
441 ms 30960 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];
void ComputeAdvice(int *C, int N, int K, int M) {
  per(i, N - 1, 0) nxt[i].pb(N);
  per(i, N - 1, 0) nxt[C[i]].pb(i);

  set < pair <int, int > > st;
  rep(i, 0, K - 1) st.insert({nxt[i].back(), i});

  int Log = log2(N) + 1;

  rep(i, 0, N - 1) {
    while (sz(st) && st.begin() -> f <= i) {
      int x = st.begin() -> s;
      st.erase(st.begin());
      nxt[x].pp();
      st.insert({nxt[x].back(), x});
    }
    if (st.count({nxt[C[i]].back(), C[i]})) {
      WriteAdvice(0);
      continue;
    }
    int del = st.rbegin() -> s;
    st.erase(--st.end());
    st.insert({nxt[C[i]].back(), C[i]});
    WriteAdvice(1);
    rep(j, 0, Log - 1) {
      WriteAdvice((del >> j) & 1);
    }
  }
}
#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(N) + 1, ptr = 0;
  for (int i = 0; i < N; i++) {
    GetRequest();
    if (A[ptr] == 0) {
      ptr++;
      continue;
    }
    else {
      ptr++;
      int val = 0;
      rep(j, 0, LOG - 1) {
        if (A[ptr + j] == 1) val |= 1 << j;
      }
      ptr += LOG;
      // cerr << val << " -> " << endl;
      PutBack(val);
    }
  }
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9968 KB Output is correct
2 Correct 8 ms 9968 KB Output is correct
3 Correct 9 ms 10168 KB Output is correct
4 Correct 15 ms 10480 KB Output is correct
5 Incorrect 10 ms 10480 KB Error - advice is too long
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 11504 KB Output is correct
2 Correct 133 ms 18232 KB Output is correct
3 Correct 340 ms 29176 KB Output is correct
4 Correct 430 ms 30192 KB Output is correct
5 Correct 441 ms 29368 KB Output is correct
6 Correct 369 ms 27992 KB Output is correct
7 Correct 321 ms 27376 KB Output is correct
8 Correct 317 ms 26776 KB Output is correct
9 Correct 404 ms 30960 KB Output is correct
10 Correct 304 ms 27776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 244 ms 23024 KB Output is correct
2 Correct 310 ms 27744 KB Output is correct
3 Correct 304 ms 27480 KB Output is correct
4 Correct 292 ms 27120 KB Output is correct
5 Correct 252 ms 26152 KB Output is correct
6 Correct 305 ms 27376 KB Output is correct
7 Correct 297 ms 27120 KB Output is correct
8 Correct 384 ms 30192 KB Output is correct
9 Correct 214 ms 26488 KB Output is correct
10 Correct 311 ms 27632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 10480 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 315 ms 26248 KB Output is partially correct - 975347 bits used
2 Partially correct 333 ms 26096 KB Output is partially correct - 941041 bits used
3 Partially correct 316 ms 26296 KB Output is partially correct - 907466 bits used
4 Partially correct 312 ms 26776 KB Output is partially correct - 906939 bits used
5 Partially correct 314 ms 26408 KB Output is partially correct - 905358 bits used
6 Partially correct 318 ms 26272 KB Output is partially correct - 907109 bits used
7 Partially correct 303 ms 26352 KB Output is partially correct - 905741 bits used
8 Partially correct 307 ms 26608 KB Output is partially correct - 908452 bits used
9 Partially correct 303 ms 26352 KB Output is partially correct - 907874 bits used
10 Partially correct 379 ms 28912 KB Output is partially correct - 1366636 bits used