답안 #288153

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
288153 2020-09-01T09:21:00 Z ToMmyDong 최후의 만찬 (IOI12_supper) C++11
17 / 100
639 ms 27576 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);

    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);
        }
        int info = flag ? pos[req] : BB;
        for (int j=0; j<15; j++) {
            WriteAdvice((info>>j) & 1);
        }
    }
    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);

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

        int kid = 0;
        for (int j=0; j<15; j++) {
            if (a[ptr++]) kid += 1<<j;
        }
        debug(kid);
        if (kid != BB) {
            PutBack(pl[kid]);
            pl[kid] = req;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 784 KB Output is correct
2 Correct 1 ms 644 KB Output is correct
3 Correct 5 ms 1068 KB Output is correct
4 Correct 13 ms 1268 KB Output is correct
5 Incorrect 5 ms 1280 KB Error - advice is too long
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 2304 KB Output is correct
2 Correct 237 ms 9168 KB Output is correct
3 Incorrect 556 ms 27576 KB Error - Not putting back color when it is not on the scaffold
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 440 ms 18688 KB Output is correct
2 Correct 565 ms 24032 KB Output is correct
3 Correct 595 ms 24520 KB Output is correct
4 Correct 563 ms 24168 KB Output is correct
5 Correct 509 ms 21208 KB Output is correct
6 Correct 613 ms 24632 KB Output is correct
7 Correct 564 ms 24520 KB Output is correct
8 Correct 552 ms 27088 KB Output is correct
9 Correct 484 ms 21960 KB Output is correct
10 Correct 552 ms 24528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1024 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 561 ms 22224 KB Output is partially correct - 1500000 bits used
2 Correct 575 ms 22848 KB Output is partially correct - 1500000 bits used
3 Correct 636 ms 23240 KB Output is partially correct - 1500000 bits used
4 Correct 585 ms 23248 KB Output is partially correct - 1500000 bits used
5 Correct 639 ms 23240 KB Output is partially correct - 1500000 bits used
6 Correct 593 ms 23504 KB Output is partially correct - 1500000 bits used
7 Correct 586 ms 23544 KB Output is partially correct - 1497585 bits used
8 Correct 593 ms 23352 KB Output is partially correct - 1500000 bits used
9 Correct 599 ms 23248 KB Output is partially correct - 1500000 bits used
10 Correct 587 ms 25800 KB Output is partially correct - 1500000 bits used