답안 #575127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
575127 2022-06-09T17:26:09 Z FatihSolak 최후의 만찬 (IOI12_supper) C++17
0 / 100
109 ms 17184 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *c, int n, int k, int m){
    vector<int> occ[n];
    int deltime[n];
    bool ok[n];
    for(int i = 0;i<n;i++){
        deltime[i] = n;
        ok[i] = 0;
        occ[i].push_back(n);
    }
    for(int i = n-1;i>=0;i--){
        occ[c[i]].push_back(i);
    }
    set<pair<int,int>> s;
    for(int i = 0;i<k;i++){
        s.insert({occ[i].back(),i});
        ok[i] = 1;
    }
    int del[n];
    for(int i = 0;i<n;i++){
        del[i] = -1;
        if(ok[c[i]]){
            s.erase({occ[c[i]].back(),c[i]});
        }
        occ[c[i]].pop_back();
        if(!ok[c[i]]){
            del[i] = s.rbegin()->second;
            ok[s.rbegin()->second] = 0;
            s.erase(*s.rbegin());
            ok[c[i]] = 1;
            s.insert({occ[c[i]].back(),c[i]});
        }
    }
    bool advice[k+n];
    int pt = k + n - 1;
    for(int i = 0;i<n;i++){
        occ[i].clear();
    }
    for(int i = 0;i<n;i++){
        occ[c[i]].push_back(i);
    }
    for(int i = 0;i<n;i++){
        occ[i].push_back(n);
    }
    for(int i = n-1;i>=0;i--){
        if(del[i] != -1){
            deltime[del[i]] = i;
        }
        if(deltime[c[i]] < occ[c[i]].back())
            advice[pt--] = 1;
        else advice[pt--] = 0;
        occ[c[i]].pop_back();
    }
    for(int i = k-1;i>=0;i--){
        if(deltime[i] < occ[i].back())
            advice[pt--] = 1;
        else advice[pt--] = 0;
    }
    for(int i = 0;i<n+k;i++){
        WriteAdvice(advice[i]);
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
void Assist(unsigned char *a, int n, int k, int r) {
    set<int> s;
    bool ok[n];    
    int last = 0;
    for(int i =  0;i<n;i++){
        ok[i] = 0;
    }
    for(int i = 0;i<k;i++){
        if(a[last++] == 1){
            s.insert(i);
        }    
        ok[i] = 1;
    }
    for (int i = 0; i < n; i++) {
        int req = GetRequest();
        if(ok[req] == 0){
            int num = *s.begin();
            s.erase(s.begin()); 
            PutBack(num);
            ok[req] = 1;
            ok[num] = 0;
        }
        if(a[last++] == 1){
            s.insert(req);
        }
    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Runtime error 1 ms 428 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 2004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 37 ms 13800 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1072 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 52 ms 16716 KB Execution killed with signal 11
2 Incorrect 105 ms 12652 KB Output isn't correct - not an optimal way
3 Incorrect 109 ms 12804 KB Output isn't correct - not an optimal way
4 Incorrect 94 ms 12984 KB Output isn't correct - not an optimal way
5 Runtime error 48 ms 17120 KB Execution killed with signal 11
6 Incorrect 93 ms 13068 KB Output isn't correct - not an optimal way
7 Incorrect 96 ms 12924 KB Output isn't correct - not an optimal way
8 Incorrect 94 ms 12820 KB Output isn't correct - not an optimal way
9 Runtime error 48 ms 17184 KB Execution killed with signal 11
10 Correct 102 ms 12232 KB Output is correct - 125000 bits used