답안 #632714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
632714 2022-08-20T16:47:59 Z Iwanttobreakfree 최후의 만찬 (IOI12_supper) C++17
0 / 100
36 ms 2840 KB
//#include "assistant.h"
#include "advisor.h"
#include <vector>
#include <set>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
    for(int i=0;i<N;i++){
        int x=C[i];
        for(int j=0;j<20;j++){
            if(x&1)WriteAdvice(1);
            else WriteAdvice(0);
            x/=2;
        }
    }
}
/*void Assist(unsigned char *A, int N, int K, int R) {
      vector<int> V(N),cnt(N);
      set<int> S;
      set<pair<int,int>> M;
      for(int i=0;i<K;i++)S.insert(i);
      for(int i=0;i<N*20;i+=20){
        for(int j=19;j>=0;j--){
            V[i]*=2;
            V[i]+=A[i+j];
        }
      }
      vector<vector<int>> needed(N,vector<int>());
      for(int i=0;i<N;i++)needed[i].push_back(N);
      for(int i=N-1;i>=0;i++)needed[V[i]].push_back(i);
      for(int i=0;i<K;i++){
        M.insert({-needed[i].back(),i});
      }
      for(int i=0;i<N;i++)cnt[i]=needed[i].size()-1;
      for (int i = 0; i < N; i++) {
        int req = GetRequest();
        if (S.find(req)==S.end()){
            auto it=M.begin();
            S.erase(it->second);
            S.insert(req);
            PutBack(it->second);
            M.erase(it);
            cnt[req]--;
            M.insert({-needed[req][cnt[req]],req});
        }
        else{
            M.erase({-needed[req][cnt[req]],req});
            cnt[req]--;
            M.insert({-needed[req][cnt[req]],req});
        }
      }

}*/
#include "assistant.h"
//#include "advisor.h"
#include <vector>
#include <set>
using namespace std;
/*void ComputeAdvice(int *C, int N, int K, int M) {
    for(int i=0;i<N;i++){
        int x=C[i];
        for(int j=0;j<20;j++){
            if(x&1)WriteAdvice(1);
            else WriteAdvice(0);
            x/=2;
        }
    }
}*/
void Assist(unsigned char *A, int N, int K, int R) {
      vector<int> V(N),cnt(N);
      set<int> S;
      set<pair<int,int>> M;
      for(int i=0;i<K;i++)S.insert(i);
      for(int i=0;i<N*20;i+=20){
        for(int j=19;j>=0;j--){
            V[i]*=2;
            V[i]+=A[i+j];
        }
      }
      vector<vector<int>> needed(N,vector<int>());
      for(int i=0;i<N;i++)needed[i].push_back(N);
      for(int i=N-1;i>=0;i++)needed[V[i]].push_back(i);
      for(int i=0;i<K;i++){
        M.insert({-needed[i].back(),i});
      }
      for(int i=0;i<N;i++)cnt[i]=needed[i].size()-1;
      for (int i = 0; i < N; i++) {
        int req = GetRequest();
        if (S.find(req)==S.end()){
            auto it=M.begin();
            S.erase(it->second);
            S.insert(req);
            PutBack(it->second);
            M.erase(it);
            cnt[req]--;
            M.insert({-needed[req][cnt[req]],req});
        }
        else{
            M.erase({-needed[req][cnt[req]],req});
            cnt[req]--;
            M.insert({-needed[req][cnt[req]],req});
        }
      }

}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 36 ms 2840 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 2280 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 516 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 2584 KB Error - advice is too long
2 Incorrect 28 ms 2552 KB Error - advice is too long
3 Incorrect 20 ms 2736 KB Error - advice is too long
4 Incorrect 19 ms 2684 KB Error - advice is too long
5 Incorrect 19 ms 2640 KB Error - advice is too long
6 Incorrect 19 ms 2768 KB Error - advice is too long
7 Incorrect 22 ms 2568 KB Error - advice is too long
8 Incorrect 19 ms 2704 KB Error - advice is too long
9 Incorrect 19 ms 2700 KB Error - advice is too long
10 Incorrect 22 ms 2684 KB Error - advice is too long