Submission #118574

# Submission time Handle Problem Language Result Execution time Memory
118574 2019-06-19T09:08:56 Z win11905 Last supper (IOI12_supper) C++11
40 / 100
682 ms 150512 KB
#include <bits/stdc++.h>
#include "advisor.h"
#define pii pair<int, int>
#define x first
#define y second
using namespace std;

const int N = 1e5+5;

static queue<int> pos[N];
static bool inq[N];

void ComputeAdvice(int *C, int N, int K, int M) {
  int bt = log2(N);
  for(int i = 0; i < N; ++i) pos[C[i]].emplace(i);
  for(int i = 0; i < N; ++i) pos[i].emplace(N);
  set<pii, greater<pii> > Q;
  for(int i = 0; i < K; ++i) Q.emplace(pos[i].front(), i), inq[i] = true;
  for(int i = 0; i < N; ++i) {
    if(inq[C[i]]) {
      Q.erase(pii(pos[C[i]].front(), i));
    } else {
      int v = Q.begin()->y; Q.erase(Q.begin());
      inq[v] = false, inq[C[i]] = true;
      for(int i = 0; i <= bt; ++i) WriteAdvice(v >> i & 1);
    } 
    pos[C[i]].pop();
    Q.emplace(pos[C[i]].front(), C[i]);
  }
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std; 

void Assist(unsigned char *A, int N, int K, int R) {
  int bt = log2(N);
  set<int> S; 
  for(int i = 0; i < K; ++i) S.emplace(i);
  int ptr = 0;
  for(int i = 0; i < N; ++i) {
    int v;
    if(S.count(v = GetRequest())) continue;
    int val = 0;
    for(int i = 0; i <= bt; ++i) if(A[ptr++]) val |= (1 << i);
    PutBack(val);
    S.erase(val);
    S.emplace(v);
  }
}
# Verdict Execution time Memory Grader output
1 Correct 66 ms 135664 KB Output is correct
2 Correct 65 ms 135408 KB Output is correct
3 Correct 66 ms 135664 KB Output is correct
4 Correct 71 ms 135664 KB Output is correct
5 Correct 78 ms 135920 KB Output is correct
6 Correct 84 ms 135664 KB Output is correct
7 Correct 73 ms 135832 KB Output is correct
8 Correct 86 ms 135920 KB Output is correct
9 Correct 79 ms 135920 KB Output is correct
10 Correct 77 ms 135920 KB Output is correct
11 Correct 77 ms 135880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 136432 KB Output is correct
2 Correct 187 ms 141552 KB Output is correct
3 Correct 435 ms 150512 KB Output is correct
4 Correct 483 ms 147440 KB Output is correct
5 Correct 435 ms 147440 KB Output is correct
6 Correct 412 ms 147776 KB Output is correct
7 Correct 396 ms 148976 KB Output is correct
8 Correct 389 ms 147696 KB Output is correct
9 Correct 514 ms 147224 KB Output is correct
10 Correct 379 ms 149744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 319 ms 146672 KB Output is correct
2 Correct 611 ms 149744 KB Output is correct
3 Correct 404 ms 149752 KB Output is correct
4 Correct 359 ms 149552 KB Output is correct
5 Correct 320 ms 148720 KB Output is correct
6 Correct 682 ms 149576 KB Output is correct
7 Correct 394 ms 149704 KB Output is correct
8 Correct 449 ms 149904 KB Output is correct
9 Correct 313 ms 149488 KB Output is correct
10 Correct 387 ms 149496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 135408 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 378 ms 149112 KB Output is partially correct - 875347 bits used
2 Partially correct 641 ms 149232 KB Output is partially correct - 841041 bits used
3 Partially correct 377 ms 149672 KB Output is partially correct - 807466 bits used
4 Partially correct 385 ms 149488 KB Output is partially correct - 806939 bits used
5 Partially correct 372 ms 149696 KB Output is partially correct - 805358 bits used
6 Partially correct 394 ms 149640 KB Output is partially correct - 807109 bits used
7 Partially correct 372 ms 149496 KB Output is partially correct - 805902 bits used
8 Partially correct 365 ms 149488 KB Output is partially correct - 808452 bits used
9 Partially correct 386 ms 149488 KB Output is partially correct - 807874 bits used
10 Partially correct 431 ms 149744 KB Output is partially correct - 1266636 bits used