답안 #744054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744054 2023-05-18T07:43:20 Z boyliguanhan 최후의 만찬 (IOI12_supper) C++17
0 / 100
1629 ms 14008 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];
    iota(s, s+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;
            for(int j = 0; j < K; j++) if(s[j]==x) res[i] = j, s[j] = 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];
      |                ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Incorrect 1 ms 512 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 1656 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 897 ms 11248 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 636 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1265 ms 13964 KB Output isn't correct - not an optimal way
2 Incorrect 1342 ms 13892 KB Output isn't correct - not an optimal way
3 Incorrect 1580 ms 13920 KB Output isn't correct - not an optimal way
4 Incorrect 1629 ms 13820 KB Output isn't correct - not an optimal way
5 Incorrect 1580 ms 13896 KB Output isn't correct - not an optimal way
6 Incorrect 1468 ms 13888 KB Output isn't correct - not an optimal way
7 Incorrect 1317 ms 13924 KB Output isn't correct - not an optimal way
8 Incorrect 1304 ms 13844 KB Output isn't correct - not an optimal way
9 Incorrect 1315 ms 14008 KB Output isn't correct - not an optimal way
10 Correct 1601 ms 13828 KB Output is partially correct - 1500000 bits used