답안 #251306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251306 2020-07-20T17:18:48 Z eohomegrownapps 최후의 만찬 (IOI12_supper) C++14
0 / 100
378 ms 141576 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()){
            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 0 ms 780 KB Output is correct
2 Incorrect 0 ms 772 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 14592 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 273 ms 113648 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 6400 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 324 ms 140576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 351 ms 140784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 345 ms 141296 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 330 ms 141576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 354 ms 141456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 378 ms 141296 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 346 ms 141296 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 343 ms 141296 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Incorrect 340 ms 141400 KB Error - Putting back a color that is not on the scaffold
10 Correct 303 ms 141040 KB Output is correct - 96843 bits used