Submission #251300

# Submission time Handle Problem Language Result Execution time Memory
251300 2020-07-20T17:07:51 Z eohomegrownapps Last supper (IOI12_supper) C++14
43 / 100
530 ms 145648 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 {
            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));
            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);
    }
    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 776 KB Output is correct
2 Correct 2 ms 772 KB Output is correct
3 Correct 3 ms 2048 KB Output is correct
4 Correct 6 ms 4608 KB Output is correct
5 Correct 5 ms 7424 KB Output is correct
6 Correct 17 ms 7424 KB Output is correct
7 Correct 8 ms 7680 KB Output is correct
8 Correct 17 ms 7936 KB Output is correct
9 Correct 16 ms 7680 KB Output is correct
10 Correct 13 ms 7936 KB Output is correct
11 Correct 15 ms 7680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 14592 KB Output is correct
2 Correct 148 ms 70640 KB Output is correct
3 Correct 469 ms 145648 KB Output is correct
4 Correct 270 ms 138480 KB Output is correct
5 Correct 364 ms 139248 KB Output is correct
6 Correct 409 ms 140280 KB Output is correct
7 Correct 414 ms 142320 KB Output is correct
8 Correct 438 ms 122864 KB Output is correct
9 Correct 207 ms 135472 KB Output is correct
10 Correct 417 ms 144184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 333 ms 114416 KB Output is correct
2 Correct 456 ms 142064 KB Output is correct
3 Correct 405 ms 142320 KB Output is correct
4 Correct 389 ms 142064 KB Output is correct
5 Correct 329 ms 139248 KB Output is correct
6 Correct 407 ms 143344 KB Output is correct
7 Correct 405 ms 143344 KB Output is correct
8 Correct 530 ms 144112 KB Output is correct
9 Correct 301 ms 142576 KB Output is correct
10 Correct 413 ms 143344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6400 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 425 ms 141272 KB Output is partially correct - 772365 bits used
2 Correct 411 ms 141552 KB Output is partially correct - 742095 bits used
3 Correct 434 ms 142064 KB Output is partially correct - 712470 bits used
4 Correct 420 ms 142152 KB Output is partially correct - 712005 bits used
5 Correct 424 ms 142320 KB Output is partially correct - 710610 bits used
6 Correct 420 ms 142576 KB Output is partially correct - 712155 bits used
7 Correct 432 ms 141808 KB Output is partially correct - 711090 bits used
8 Correct 443 ms 142064 KB Output is partially correct - 713340 bits used
9 Correct 453 ms 142064 KB Output is partially correct - 712830 bits used
10 Correct 480 ms 142832 KB Output is partially correct - 1117620 bits used