답안 #575130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
575130 2022-06-09T17:34:08 Z FatihSolak 최후의 만찬 (IOI12_supper) C++17
100 / 100
145 ms 13720 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;
        /*
        for(auto u:s){
            cout << u.second << " ";
        }
        cout << endl;*/
        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 0 ms 516 KB Output is correct
2 Correct 0 ms 508 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 3 ms 796 KB Output is correct
5 Correct 5 ms 1040 KB Output is correct
6 Correct 4 ms 948 KB Output is correct
7 Correct 6 ms 1204 KB Output is correct
8 Correct 4 ms 1092 KB Output is correct
9 Correct 4 ms 1176 KB Output is correct
10 Correct 5 ms 1184 KB Output is correct
11 Correct 6 ms 1208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1620 KB Output is correct
2 Correct 47 ms 6324 KB Output is correct
3 Correct 141 ms 13032 KB Output is correct
4 Correct 71 ms 10984 KB Output is correct
5 Correct 94 ms 11064 KB Output is correct
6 Correct 142 ms 11416 KB Output is correct
7 Correct 108 ms 12268 KB Output is correct
8 Correct 82 ms 10592 KB Output is correct
9 Correct 79 ms 11484 KB Output is correct
10 Correct 145 ms 12864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 9240 KB Output is correct
2 Correct 132 ms 12600 KB Output is correct
3 Correct 111 ms 12720 KB Output is correct
4 Correct 118 ms 12740 KB Output is correct
5 Correct 124 ms 12808 KB Output is correct
6 Correct 119 ms 12964 KB Output is correct
7 Correct 115 ms 12656 KB Output is correct
8 Correct 98 ms 12228 KB Output is correct
9 Correct 115 ms 13720 KB Output is correct
10 Correct 117 ms 12756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 920 KB Output is correct
2 Correct 6 ms 1052 KB Output is correct
3 Correct 5 ms 1072 KB Output is correct
4 Correct 5 ms 956 KB Output is correct
5 Correct 5 ms 1032 KB Output is correct
6 Correct 4 ms 948 KB Output is correct
7 Correct 5 ms 1212 KB Output is correct
8 Correct 5 ms 1220 KB Output is correct
9 Correct 6 ms 1212 KB Output is correct
10 Correct 8 ms 1352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 11428 KB Output is correct - 120000 bits used
2 Correct 113 ms 11460 KB Output is correct - 122000 bits used
3 Correct 115 ms 11504 KB Output is correct - 125000 bits used
4 Correct 122 ms 11552 KB Output is correct - 125000 bits used
5 Correct 121 ms 11640 KB Output is correct - 125000 bits used
6 Correct 110 ms 11540 KB Output is correct - 125000 bits used
7 Correct 115 ms 11568 KB Output is correct - 124828 bits used
8 Correct 126 ms 11536 KB Output is correct - 124910 bits used
9 Correct 133 ms 11588 KB Output is correct - 125000 bits used
10 Correct 108 ms 11068 KB Output is correct - 125000 bits used