답안 #118606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
118606 2019-06-19T09:43:35 Z Plurm 최후의 만찬 (IOI12_supper) C++11
8 / 100
2500 ms 12816 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

int FT[100005];
void add(int idx, int amt){
    idx++;
    while(idx < 100005){
        FT[idx] += amt;
        idx += idx & -idx;
    }
}
int sum(int idx){
    idx++;
    int ret = 0;
    while(idx > 0){
        ret += FT[idx];
        idx -= idx & -idx;
    }
    return ret;
}
int nxt[100005];
set<int> s[100005];
void ComputeAdvice(int *C, int N, int K, int M) {
    const int INF = 1e9;
    // Compute everything in the morning.
    // Remember only ordering of the removals.
    for(int i = 0; i < N; i++){
        s[C[i]].insert(i);
    }
    for(int i = 0; i < N; i++){
        set<int>::iterator it = s[C[i]].upper_bound(i);
        if(it == s[C[i]].end()){
            nxt[i] = INF;
        }else{
            nxt[i] = *it;
        }
    }
    set<int> use;
    vector<int> raw;
    for(int i = 0; i < K; i++){
        use.insert(i);
        add(i,1);
    }
    for(int i = 0; i < N; i++){
        if(use.find(C[i]) != use.end()){
            raw.push_back(K);
        }else{
            int curuse = -1;
            int nxtpos = 0;
            for(set<int>::iterator it = use.begin(); it != use.end(); ++it){
                int col = *it;
                set<int>::iterator nxt = s[col].upper_bound(i);
                if(nxt == s[col].end()){
                    curuse = col;
                    break;
                }
                if(*nxt > nxtpos){
                    nxtpos = *nxt;
                    curuse = col;
                }
            }
            raw.push_back(sum(curuse));
            use.erase(curuse);
            add(curuse, -1);
            use.insert(C[i]);
            add(C[i], 1);
        }
    }
    for(int i = 0; i < raw.size(); i++){
        for(int j = 0; j < 13; j++){
            if(raw[i] & (1 << j)){
                WriteAdvice(1);
            }else{
                WriteAdvice(0);
            }
        }
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

int FTS[100005];
void addS(int idx, int amt){
    idx++;
    while(idx < 100005){
        FTS[idx] += amt;
        idx += idx & -idx;
    }
}
int sumS(int idx){
    idx++;
    int ret = 0;
    while(idx > 0){
        ret += FTS[idx];
        idx -= idx & -idx;
    }
    return ret;
}
int getidx(int num){
    int lo = 0;
    int hi = 100003;
    int mid;
    while(lo < hi){
        mid = (lo + hi)/2;
        if(sumS(mid) < num){
            lo = mid+1;
        }else{
            hi = mid;
        }
    }
    return lo;
}
void Assist(unsigned char *A, int N, int K, int R) {
    vector<int> dat;
    for(int i = 0; i < R; i += 13){
        int cur = 0;
        for(int j = 0; j < 13; j++){
            if(A[i+j]){
                cur += 1 << j;
            }
        }
        dat.push_back(cur);
    }
    set<int> use;
    for(int i = 0; i < K; i++){
        use.insert(i);
        addS(i,1);
    }
    for(int i = 0; i < N; i++){
        int cur = GetRequest();
        if(use.find(cur) != use.end()) continue;
        int now = dat[i];
        int eidx = getidx(now);
        PutBack(eidx);
        use.erase(eidx);
        addS(eidx, -1);
        use.insert(cur);
        addS(cur, 1);
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:70:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < raw.size(); i++){
                    ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 10240 KB Output is correct
2 Correct 8 ms 9984 KB Output is correct
3 Correct 12 ms 10496 KB Output is correct
4 Correct 17 ms 10752 KB Output is correct
5 Correct 20 ms 11224 KB Output is correct
6 Correct 26 ms 11264 KB Output is correct
7 Correct 22 ms 11264 KB Output is correct
8 Correct 43 ms 11248 KB Output is correct
9 Correct 45 ms 11248 KB Output is correct
10 Correct 37 ms 11504 KB Output is correct
11 Correct 43 ms 11264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 146 ms 12816 KB Output is correct
2 Execution timed out 2542 ms 8780 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2542 ms 10992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 10752 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2530 ms 12124 KB Time limit exceeded
2 Execution timed out 2542 ms 12280 KB Time limit exceeded
3 Execution timed out 2538 ms 12400 KB Time limit exceeded
4 Execution timed out 2524 ms 12560 KB Time limit exceeded
5 Execution timed out 2523 ms 12400 KB Time limit exceeded
6 Execution timed out 2538 ms 12600 KB Time limit exceeded
7 Execution timed out 2531 ms 12232 KB Time limit exceeded
8 Execution timed out 2542 ms 12480 KB Time limit exceeded
9 Execution timed out 2559 ms 12428 KB Time limit exceeded
10 Execution timed out 2550 ms 12508 KB Time limit exceeded