답안 #764741

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764741 2023-06-24T02:53:21 Z ngrace 최후의 만찬 (IOI12_supper) C++14
0 / 100
187 ms 9920 KB
#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
#define v vector
#define ii pair<int,int>
#define fi first
#define se second

void ComputeAdvice(int *C, int N, int K, int M) {
  int sik = 0;
  for(int i=0; i<32; i++){
    if(K & (1<<i)) sik = i+1;
  }

  v<int> lastpos(N,N+1);
  v<int> nextpos(N);
  v<int> nextposk(K,N+1);
  for(int i=N-1; i>=0; i--){
    if(C[i]<K) nextposk[C[i]] = i;
    nextpos[i] = lastpos[C[i]];
    lastpos[C[i]] = i;
  }

  v<int> scaff(N,-1);
  priority_queue<ii> pq;
  for(int i=0; i<K; i++){
    scaff[i]=i;
    pq.push({nextposk[i], i});
  }

  for(int i=0; i<N; i++){
    int req = C[i];
    if(scaff[req]==-1){
      int rem = pq.top().se;
      pq.pop();
      int k = scaff[rem];
      scaff[req] = k;
      pq.push({nextpos[i], req});
      scaff[rem] = -1;
      
      for(int b=0; b<sik; b++) WriteAdvice((bool)(k & (1<<b)));
    }
  }

}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
#define v vector
#define ii pair<int,int>
#define fi first
#define se second

void Assist(unsigned char *A, int N, int K, int R) {
  int sik = 0;
  for(int i=0; i<32; i++){
    if(K & (1<<i)) sik = i+1;
  }

  v<int> scaff(N, -1);
  v<int> revscaff(K, -1);
  for(int i=0; i<K; i++){
    scaff[i]=i;
    revscaff[i]=i;
  }

  int aind=0;
  for(int i=0; i<N; i++){
    int req = GetRequest();
    if(scaff[req]==-1){
      int k=0;
      for(int j=0; j<sik; j++){
        if(A[aind]==1) k |= (1<<j);
        aind++;
      }
      PutBack(revscaff[k]);
      scaff[revscaff[k]]=-1;
      scaff[req]=k;
      revscaff[k]=req;
    }
  }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 520 KB Output is correct
2 Incorrect 2 ms 508 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 1444 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 127 ms 7212 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 648 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 181 ms 9204 KB Output isn't correct - not an optimal way
2 Incorrect 162 ms 9116 KB Output isn't correct - not an optimal way
3 Incorrect 150 ms 8644 KB Output isn't correct - not an optimal way
4 Incorrect 170 ms 8516 KB Output isn't correct - not an optimal way
5 Incorrect 156 ms 8652 KB Output isn't correct - not an optimal way
6 Incorrect 149 ms 8652 KB Output isn't correct - not an optimal way
7 Incorrect 154 ms 8560 KB Output isn't correct - not an optimal way
8 Incorrect 165 ms 8808 KB Output isn't correct - not an optimal way
9 Incorrect 163 ms 8580 KB Output isn't correct - not an optimal way
10 Correct 187 ms 9920 KB Output is partially correct - 1117620 bits used