Submission #251292

# Submission time Handle Problem Language Result Execution time Memory
251292 2020-07-20T16:58:02 Z eohomegrownapps Last supper (IOI12_supper) C++14
0 / 100
403 ms 14040 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<int> lastocc(n,-1);
    for (int i = 0; i<n; i++){
        lastocc[c[i]]=i;
    }
    int bitwidth = ceil(log2(k));
    set<pair<int,int>> scaffrem;
    pbds_set<int> scaff;
    for (int i = 0; i<k; i++){
        scaffrem.insert({lastocc[i],i});
        scaff.insert(i);
    }
    for (int i = 0; i<n; i++){
        if (scaff.find(c[i])!=scaff.end()){
            continue;
        } else {
            scaffrem.insert({-lastocc[c[i]],c[i]});
            scaff.insert(c[i]);
            auto toremove = prev(scaffrem.end());
            //can we get rid of one we've already used
            auto it = scaffrem.lower_bound({i,-1});
            if (it!=scaffrem.begin()){
                toremove = prev(it);
            }
            int ind = scaff.order_of_key(toremove->second);
            //transmit ind
            for (int i = bitwidth-1; i>=0; i--){
                WriteAdvice(bool((1<<i)&ind));
            }
            scaffrem.erase(toremove);
            scaff.erase(scaff.find_by_order(ind));
        }
    }
}
#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);
    }
    for (int i = 0; i<n; i++){
        int col = GetRequest();
        if (scaff.find(col)!=scaff.end()){
            continue;
        } else {
            int ind = 0;
            for (int i = 0; i<bitwidth; i++){
                ind*=2;
                ind+=A[ptr];
                ptr++;
            }
            auto putel = scaff.find_by_order(ind);
            PutBack(*putel);
            scaff.erase(putel);
            scaff.insert(col);
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 904 KB Output is correct
2 Incorrect 0 ms 784 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 1536 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 238 ms 9368 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 3 ms 1028 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 351 ms 11472 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 295 ms 11224 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 330 ms 12056 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 292 ms 11488 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 342 ms 11568 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 305 ms 11696 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 327 ms 11480 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 327 ms 11520 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 286 ms 11624 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 403 ms 14040 KB Error - Not putting back color when it is not on the scaffold