Submission #744097

# Submission time Handle Problem Language Result Execution time Memory
744097 2023-05-18T08:04:46 Z boyliguanhan Last supper (IOI12_supper) C++17
0 / 100
287 ms 14500 KB
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
    int res[N], last[N], nxt[N], s[K], where[N];
    iota(s, s+K, 0);
    iota(where, where+K, 0);
    priority_queue<pair<int, int>> q;
    memset(last, 1, sizeof last);
    for(int i = N; i--;)
        nxt[i] = last[C[i]], last[C[i]] = i;
    bool on[N];
    memset(on, 0, sizeof on);
    for(int i = 0; i < K; i++)
        q.push({last[i], i}), on[i] = 1;
    for(int i = 0; i < N; i++) {
        int col = C[i];
        if(!on[col]) {
            int x = q.top().second;
            on[x] = 0;
            res[i] = where[x];
            s[where[x]] = col;
            q.pop();
            q.push({nxt[i], col});
            on[col] = 1;
        } else res[i] = K;
    }
    int bits = log2(K)+1;
    for(int i = 0; i < N; i++)
        for(int j = 0; j < bits; j++)
            WriteAdvice((bool)(res[i]&1<<j));
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {

  priority_queue<pair<int, int>> q;
  int last[N], nxt[N];
  memset(last, 1, sizeof last);
  int C[N], bits = log2(K)+1;
  memset(C, 0, sizeof C);
  for(int i = 0; i < N; i++)
    for(int j = 0; j < bits; j++)
      C[i]|=(int)A[i*bits+j] << j;
  int scaffold[K];
  iota(scaffold, scaffold+K, 0);
  for(int i = 0; i < N; i++) {
    int x = GetRequest();
    if(C[i]<K)
      PutBack(scaffold[C[i]]), scaffold[C[i]] = x;
  }
}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:8:16: warning: unused variable 'nxt' [-Wunused-variable]
    8 |   int last[N], nxt[N];
      |                ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1684 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 Incorrect 227 ms 11568 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 Incorrect 1 ms 644 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 274 ms 14364 KB Error - Not putting back color when it is not on the scaffold
2 Incorrect 287 ms 14220 KB Error - Not putting back color when it is not on the scaffold
3 Incorrect 275 ms 14376 KB Error - Not putting back color when it is not on the scaffold
4 Incorrect 275 ms 14252 KB Error - Not putting back color when it is not on the scaffold
5 Incorrect 272 ms 14208 KB Error - Not putting back color when it is not on the scaffold
6 Incorrect 279 ms 14500 KB Error - Not putting back color when it is not on the scaffold
7 Incorrect 277 ms 14256 KB Error - Not putting back color when it is not on the scaffold
8 Incorrect 284 ms 14372 KB Error - Not putting back color when it is not on the scaffold
9 Incorrect 275 ms 14380 KB Error - Not putting back color when it is not on the scaffold
10 Incorrect 269 ms 14376 KB Error - Not putting back color when it is not on the scaffold