답안 #925412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925412 2024-02-11T14:58:29 Z anton 최후의 만찬 (IOI12_supper) C++17
40 / 100
282 ms 16864 KB
#include<bits/stdc++.h>
using namespace std;


#define pii pair<int, int>
#include "advisor.h"

const int INF = 1e9;
void ComputeAdvice(int *C, int N, int K, int M) {

  vector<int> put_down;
  vector<vector<int>> oc;

  int log2 = 1;

  while((1<<log2)<N){
    log2++;
  }

  oc.resize(N);
  for(int i = 0; i<N; i++){
    oc[C[i]].push_back(i);
  }

  for(int i = 0; i<N; i++){
    oc[i].push_back(INF);
    reverse(oc[i].begin(), oc[i].end());
  }
  
  set<pii> cur_colors;
  for(int i = 0; i<K; i++){
    cur_colors.insert({oc[i].back(), i});
  }
  
  for(int i = 0; i<N; i++){
    
    int needed = C[i];
    if(cur_colors.find({oc[C[i]].back(), C[i]}) == cur_colors.end()){
      pii removing = *(--cur_colors.end());
      cur_colors.erase(removing);
      put_down.push_back(removing.second);
    }
    else{
      cur_colors.erase({oc[needed].back(), needed});
    }
    oc[needed].pop_back();
    cur_colors.insert({oc[needed].back(), needed});

    
  }

  for(auto e: put_down){
    for(int i = 0; i<log2; i++){
      WriteAdvice((e&(1<<i))>>i);
    }
  }

}
#include<bits/stdc++.h>
using namespace std;


#define pii pair<int, int>

#include "assistant.h"

void Assist(unsigned char *A, int N, int K, int R) {
  int log2 = 1;

  while((1<<log2)<N){
    log2++;
  }
  set<int> cur_colors;
  for(int i = 0; i<K; i++){
    cur_colors.insert(i);
  }
  vector<int> put_down;
  for(int i =0; i<R; i+=log2){
    int val = 0;
    for(int j = 0; j<log2; j++){
      val += A[j+i] * (1<<j);
    }
    put_down.push_back(val);
  }

  reverse(put_down.begin(), put_down.end());
  
  for (int i = 0; i < N; i++) {
    int req = GetRequest();
    if(cur_colors.find(req) == cur_colors.end()){
      PutBack(put_down.back());
      cur_colors.erase(put_down.back());
      put_down.pop_back();
    }
    cur_colors.insert(req);
  }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 792 KB Output is correct
2 Correct 0 ms 784 KB Output is correct
3 Correct 1 ms 780 KB Output is correct
4 Correct 5 ms 1100 KB Output is correct
5 Correct 11 ms 1456 KB Output is correct
6 Correct 11 ms 1428 KB Output is correct
7 Correct 4 ms 1072 KB Output is correct
8 Correct 11 ms 1680 KB Output is correct
9 Correct 11 ms 1432 KB Output is correct
10 Correct 7 ms 1364 KB Output is correct
11 Correct 9 ms 1384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 1900 KB Output is correct
2 Correct 83 ms 6548 KB Output is correct
3 Correct 240 ms 16480 KB Output is correct
4 Correct 279 ms 16688 KB Output is correct
5 Correct 282 ms 16428 KB Output is correct
6 Correct 242 ms 14612 KB Output is correct
7 Correct 215 ms 13864 KB Output is correct
8 Correct 222 ms 14048 KB Output is correct
9 Correct 265 ms 16864 KB Output is correct
10 Correct 203 ms 14148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 11312 KB Output is correct
2 Correct 204 ms 13876 KB Output is correct
3 Correct 201 ms 13776 KB Output is correct
4 Correct 200 ms 13536 KB Output is correct
5 Correct 159 ms 12108 KB Output is correct
6 Correct 205 ms 13788 KB Output is correct
7 Correct 197 ms 13696 KB Output is correct
8 Correct 253 ms 16584 KB Output is correct
9 Correct 144 ms 12516 KB Output is correct
10 Correct 206 ms 13772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1044 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 217 ms 13820 KB Output is partially correct - 875347 bits used
2 Correct 210 ms 13552 KB Output is partially correct - 841041 bits used
3 Correct 206 ms 14024 KB Output is partially correct - 807466 bits used
4 Correct 203 ms 13936 KB Output is partially correct - 806939 bits used
5 Correct 202 ms 13776 KB Output is partially correct - 805358 bits used
6 Correct 207 ms 13776 KB Output is partially correct - 807109 bits used
7 Correct 201 ms 13792 KB Output is partially correct - 805902 bits used
8 Correct 210 ms 13948 KB Output is partially correct - 808452 bits used
9 Correct 202 ms 13780 KB Output is partially correct - 807874 bits used
10 Correct 253 ms 16556 KB Output is partially correct - 1266636 bits used