Submission #251290

# Submission time Handle Problem Language Result Execution time Memory
251290 2020-07-20T16:56:30 Z eohomegrownapps Last supper (IOI12_supper) C++14
0 / 100
474 ms 14488 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 {
            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));
            scaffrem.insert({-lastocc[c[i]],c[i]});
            scaff.insert(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);
    }
    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 0 ms 772 KB Output is correct
2 Correct 0 ms 780 KB Output is correct
3 Correct 2 ms 940 KB Output is correct
4 Incorrect 4 ms 836 KB Output isn't correct - not an optimal way
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 1792 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 259 ms 9488 KB Output is correct
2 Correct 343 ms 12760 KB Output is correct
3 Correct 330 ms 12768 KB Output is correct
4 Correct 328 ms 12504 KB Output is correct
5 Incorrect 315 ms 10944 KB Output isn't correct - not an optimal way
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1048 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 384 ms 11504 KB Output isn't correct - not an optimal way
2 Correct 347 ms 11488 KB Output is partially correct - 742095 bits used
3 Correct 336 ms 11728 KB Output is partially correct - 712470 bits used
4 Correct 351 ms 11744 KB Output is partially correct - 712005 bits used
5 Correct 340 ms 11992 KB Output is partially correct - 710610 bits used
6 Correct 332 ms 11752 KB Output is partially correct - 712155 bits used
7 Correct 355 ms 11744 KB Output is partially correct - 711090 bits used
8 Correct 336 ms 11752 KB Output is partially correct - 713340 bits used
9 Correct 339 ms 11864 KB Output is partially correct - 712830 bits used
10 Correct 474 ms 14488 KB Output is partially correct - 1117620 bits used