답안 #251311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251311 2020-07-20T17:27:06 Z eohomegrownapps 최후의 만찬 (IOI12_supper) C++14
0 / 100
349 ms 141552 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&&nextocc[c[i-1]].size()==0){
                WriteAdvice(1);
                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()){
            prevcol=col;
            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(prevcol);
            scaff.erase(putel);
            scaff.insert(col);
        }
        prevcol=col;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 772 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 14592 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 227 ms 113688 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 6400 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 314 ms 140536 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 306 ms 140784 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 302 ms 141552 KB Error - Not putting back color when it is not on the scaffold
4 Incorrect 341 ms 141304 KB Error - Not putting back color when it is not on the scaffold
5 Incorrect 293 ms 141552 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 298 ms 141296 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 317 ms 141296 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 295 ms 141392 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 349 ms 141552 KB Error - Not putting back color when it is not on the scaffold
10 Incorrect 290 ms 141040 KB Error - Putting back a color that is not on the scaffold