답안 #288189

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
288189 2020-09-01T09:42:01 Z ToMmyDong 최후의 만찬 (IOI12_supper) C++11
46 / 100
388 ms 19648 KB
#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 "advisor.h"


const int BB = 25001;
void ComputeAdvice(int *c, int n, int k, int m) {

    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;
    map<int,int> pos;
    for (int i=0; i<k; i++) {
        pos[i] = i;
        pq.emplace(pii(lst[i], i));
        st.insert(i);
        debug(lst[i], i);
    }
    vector<int> pl(k);
    iota(pl.begin(), pl.end(), 0);
    int prv = -1;

    for (int i=0; i<n; i++) {
        int req = c[i];
        assert(c[i] == req);
        bool flag = true;
        if (!st.count(req)) {
            pii cur = *prev(pq.end());
            pq.erase(prev(pq.end()));
            debug(cur);
            debug(nxt[i], req);
            pl[pos[cur.Y]] = req;
            pos[req] = pos[cur.Y];

            st.erase(cur.Y);
            st.insert(req);
            pq.emplace(nxt[i], req);
        } else {
            flag = false;
            pq.erase({i, req});
            pq.emplace(nxt[i], req);
        }
        WriteAdvice(flag);
        if (flag) {
            int info = pos[req];
            WriteAdvice(info == prv);
            if (info == prv) continue;
            for (int j=0; j<15; j++) {
                WriteAdvice((info>>j) & 1);
            }
            prv = info;
        }
    }
    debug("done");
}
#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"

const int BB = 25001;
void Assist(unsigned char *a, int n, int k, int r) {

    vector<int> pl(k);
    iota(ALL(pl), 0);

    int prv = -1;
    for (int i=0, ptr=0; i<n; i++) {
        int req = GetRequest();

        if (!a[ptr++]) continue;
        int kid = 0;
        if (a[ptr++]) {
            kid = prv;
        } else {
            for (int j=0; j<15; j++) {
                if (a[ptr++]) kid += 1<<j;
            }
            prv = kid;
        }
        debug(kid);
        PutBack(pl[kid]);
        pl[kid] = req;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 788 KB Output is correct
2 Correct 1 ms 900 KB Output is correct
3 Correct 3 ms 1024 KB Output is correct
4 Correct 8 ms 956 KB Output is correct
5 Correct 7 ms 1072 KB Output is correct
6 Correct 13 ms 1300 KB Output is correct
7 Correct 8 ms 1136 KB Output is correct
8 Correct 9 ms 1536 KB Output is correct
9 Correct 14 ms 1536 KB Output is correct
10 Correct 13 ms 1792 KB Output is correct
11 Correct 15 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 2048 KB Output is correct
2 Correct 142 ms 6096 KB Output is correct
3 Incorrect 304 ms 19648 KB Error - Not putting back color when it is not on the scaffold
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 269 ms 14416 KB Output is correct
2 Correct 349 ms 17616 KB Output is correct
3 Correct 351 ms 17864 KB Output is correct
4 Correct 339 ms 17352 KB Output is correct
5 Correct 294 ms 14256 KB Output is correct
6 Correct 358 ms 17872 KB Output is correct
7 Correct 345 ms 17608 KB Output is correct
8 Correct 246 ms 17944 KB Output is correct
9 Correct 251 ms 14544 KB Output is correct
10 Correct 346 ms 17872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1288 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 388 ms 16840 KB Output is partially correct - 635946 bits used
2 Correct 373 ms 17352 KB Output is partially correct - 617533 bits used
3 Correct 366 ms 18128 KB Output is partially correct - 594288 bits used
4 Correct 350 ms 17872 KB Output is partially correct - 594857 bits used
5 Correct 338 ms 17864 KB Output is partially correct - 599474 bits used
6 Correct 354 ms 17864 KB Output is partially correct - 596352 bits used
7 Correct 365 ms 17864 KB Output is partially correct - 595190 bits used
8 Correct 365 ms 17864 KB Output is partially correct - 595111 bits used
9 Correct 352 ms 17872 KB Output is partially correct - 596262 bits used
10 Correct 265 ms 17872 KB Output is correct - 195868 bits used