Submission #251309

# Submission time Handle Problem Language Result Execution time Memory
251309 2020-07-20T17:25:34 Z eohomegrownapps Last supper (IOI12_supper) C++14
0 / 100
312 ms 141808 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&&c[i]!=c[i-1]){
                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(prevcol);
            scaff.erase(putel);
            scaff.insert(col);
        }
        prevcol=col;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 776 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 14592 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 228 ms 113656 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 6400 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 283 ms 140504 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 311 ms 140784 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 299 ms 141560 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 288 ms 141552 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 299 ms 141808 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 289 ms 141296 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 292 ms 141136 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 294 ms 141296 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 312 ms 141552 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 256 ms 140952 KB Error - Putting back a color that is not on the scaffold