답안 #251305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251305 2020-07-20T17:17:36 Z eohomegrownapps 최후의 만찬 (IOI12_supper) C++14
0 / 100
329 ms 141560 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#include <bits/extc++.h>
using namespace __gnu_pbds;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T, typename V>
using pbds_map = tree<T, V, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void ComputeAdvice(int *c, int n, int k, int m) {
    vector<queue<int>> nextocc(n);
    for (int i = 0; i<n; i++){
        nextocc[c[i]].push(i);
    }
    int bitwidth = ceil(log2(k));
    set<pair<int,int>> scaffrem;
    pbds_set<int> scaff;
    for (int i = 0; i<k; i++){
        if (nextocc[i].size()>0){
            scaffrem.insert({nextocc[i].front(),i});
        } else {
            scaffrem.insert({n,i});
        }
        scaff.insert(i);
    }
    for (int i = 0; i<n; i++){
        if (scaff.find(c[i])!=scaff.end()){
            scaffrem.erase({nextocc[c[i]].front(),c[i]});
        } else {
            //check if the one we just put on can be removed
            auto toremove = prev(scaffrem.end());
            int ind;
            if (i>0){
                WriteAdvice(1);
                if (nextocc[c[i-1]].size()==0){
                    toremove = scaffrem.find({n,c[i-1]});
                }
                ind = scaff.order_of_key(toremove->second);
            } else {
                WriteAdvice(0);
                //can we get rid of one we've already used
                /*auto it = scaffrem.lower_bound({i,-1});
                if (it!=scaffrem.begin()){
                    toremove = prev(it);
                }*/
                //transmit ind
                ind = scaff.order_of_key(toremove->second);
                for (int i = bitwidth-1; i>=0; i--){
                    WriteAdvice(bool((1<<i)&ind));
                }
            }
            scaffrem.erase(toremove);
            scaff.erase(scaff.find_by_order(ind));
            scaff.insert(c[i]);
        }
        int newind = n;
        nextocc[c[i]].pop();
        if (nextocc[c[i]].size()>0){
            newind=nextocc[c[i]].front();
        }
        scaffrem.insert({newind,c[i]});
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
#include <bits/extc++.h>
using namespace __gnu_pbds;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T, typename V>
using pbds_map = tree<T, V, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void Assist(unsigned char *A, int n, int k, int r) {
    //GetRequest()
    //PutBack()
    int ptr = 0;
    int bitwidth = ceil(log2(k));
    pbds_set<int> scaff;
    for (int i = 0; i<k; i++){
        scaff.insert(i);
    }
    int prevcol = -1;
    for (int i = 0; i<n; i++){
        int col = GetRequest();
        if (scaff.find(col)!=scaff.end()){
            continue;
        } else {
            bool removeLast = A[ptr];
            ptr++;
            auto putel = scaff.begin();
            if (removeLast){
                putel = scaff.find(prevcol);
            } else {
                int ind = 0;
                for (int i = 0; i<bitwidth; i++){
                    ind*=2;
                    ind+=A[ptr];
                    ptr++;
                }
                putel = scaff.find_by_order(ind);
            }
            PutBack(*putel);
            scaff.erase(putel);
            scaff.insert(col);
        }
        prevcol=col;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1028 KB Output is correct
2 Incorrect 2 ms 776 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 14592 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 220 ms 113648 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 6384 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 280 ms 140408 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 277 ms 140784 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 239 ms 141560 KB Error - Not putting back color when it is not on the scaffold
4 Incorrect 311 ms 141552 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 288 ms 141552 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 326 ms 141552 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 312 ms 141040 KB Error - Not putting back color when it is not on the scaffold
8 Incorrect 291 ms 141296 KB Error - Not putting back color when it is not on the scaffold
9 Incorrect 313 ms 141296 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 329 ms 141440 KB Output isn't correct - not an optimal way