Submission #288093

# Submission time Handle Problem Language Result Execution time Memory
288093 2020-09-01T08:41:02 Z ToMmyDong Last supper (IOI12_supper) C++11
9 / 100
568 ms 20648 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(i) i.begin(), i.end()
#define SZ(i) int(i.size())
#define X first
#define Y second
#ifdef tmd
#define debug(...) fprintf(stderr,"#%d-(%s)=",__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y) {cerr<<x<<",";_do(y...);}
template<typename IT> ostream& __printRng (ostream& os, IT bg, IT ed) {
    for (IT it=bg;it!=ed;it++) {
        if (it == bg) os << "{" << *it;
        else os << "," << *it;
    }
    return os << "}";
}
template<typename T> ostream& operator << (ostream& os, const vector<T> &vec) {
    return __printRng(os, ALL(vec));
}
template<typename T, typename S> ostream& operator << (ostream& os, const pair<T,S> &pa) {
    return os << "{" << pa.X << "," << pa.Y << "}";
}
#else
#define debug(...)
#endif

#include "advisor.h"

void ComputeAdvice(int *C, int N, int K, int M) {
    for (int i=0; i<N; i++) {
        for (int j=0; j<20; j++) {
            WriteAdvice((C[i]>>j)&1);
        }
    }
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define ALL(i) i.begin(), i.end()
#define SZ(i) int(i.size())
#define X first
#define Y second
#ifdef tmd
#define debug(...) fprintf(stderr,"#%d-(%s)=",__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y) {cerr<<x<<",";_do(y...);}
template<typename IT> ostream& __printRng (ostream& os, IT bg, IT ed) {
    for (IT it=bg;it!=ed;it++) {
        if (it == bg) os << "{" << *it;
        else os << "," << *it;
    }
    return os << "}";
}
template<typename T> ostream& operator << (ostream& os, const vector<T> &vec) {
    return __printRng(os, ALL(vec));
}
template<typename T, typename S> ostream& operator << (ostream& os, const pair<T,S> &pa) {
    return os << "{" << pa.X << "," << pa.Y << "}";
}
#else
#define debug(...)
#endif

#include "assistant.h"

void Assist(unsigned char *a, int n, int k, int r) {

    vector<int> c(n);
    for (int i=0, ptr=0; i<n; i++) {
        for (int j=0; j<20; j++) {
            if (a[ptr++]) c[i] += (1<<j);
        }
    }

    vector<int> nxt(n);
    vector<int> lst(n, n);
    for (int i=n-1; i>=0; i--) {
        nxt[i] = lst[c[i]];
        lst[c[i]] = i;
    }

    set<pii> pq;
    set<int> st;
    for (int i=0; i<k; i++) {
        pq.emplace(pii(lst[i], i));
        st.insert(i);
        debug(lst[i], i);
    }
    for (int i=0; i<n; i++) {
        int req = GetRequest();
        assert(c[i] == req);
        if (!st.count(req)) {
            pii cur = *prev(pq.end());
            pq.erase(prev(pq.end()));
            debug(cur);
            debug(nxt[i], req);

            PutBack(cur.Y);
            st.erase(cur.Y);
            st.insert(req);
            pq.emplace(nxt[i], req);
        } else {
            pq.erase({i, req});
            pq.emplace(nxt[i], req);
        }
    }


}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 784 KB Output is correct
2 Correct 2 ms 916 KB Output is correct
3 Correct 6 ms 1028 KB Output is correct
4 Correct 16 ms 1224 KB Output is correct
5 Incorrect 1 ms 956 KB Error - advice is too long
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 52 ms 2584 KB Output is correct
2 Correct 264 ms 9676 KB Output is correct
3 Correct 566 ms 20648 KB Output is correct
4 Correct 497 ms 17432 KB Output is correct
5 Correct 512 ms 17208 KB Output is correct
6 Correct 530 ms 17596 KB Output is correct
7 Correct 568 ms 18880 KB Output is correct
8 Correct 452 ms 17060 KB Output is correct
9 Correct 501 ms 16984 KB Output is correct
10 Correct 556 ms 20156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 4096 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1020 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 5056 KB Error - advice is too long
2 Incorrect 27 ms 4848 KB Error - advice is too long
3 Incorrect 22 ms 4848 KB Error - advice is too long
4 Incorrect 22 ms 4848 KB Error - advice is too long
5 Incorrect 23 ms 5120 KB Error - advice is too long
6 Incorrect 22 ms 4864 KB Error - advice is too long
7 Incorrect 22 ms 4864 KB Error - advice is too long
8 Incorrect 22 ms 4864 KB Error - advice is too long
9 Incorrect 23 ms 4864 KB Error - advice is too long
10 Incorrect 22 ms 5120 KB Error - advice is too long