답안 #269565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
269565 2020-08-17T07:52:48 Z PeppaPig 최후의 만찬 (IOI12_supper) C++14
0 / 100
515 ms 14472 KB
#include "advisor.h"
#include <bits/stdc++.h>

#define pii pair<int, int>
#define x first
#define y second

using namespace std;

static const int N = 1e5 + 5;

static int t[N];

static void update(int x, int k) {
    for(int i = x + 1; i < N; i += i & -i)
        t[i] += k;
}

static int query(int x, int ret = 0) {
    for(int i = x + 1; i; i -= i & -i)
        ret += t[i];
    return ret;
}

static int col[N];

void ComputeAdvice(int *C, int n, int k, int M) {
    for(int i = 0; i < n; i++) col[i] = lower_bound(C, C + n, i) - C;

    priority_queue<pii> Q;
    for(int i = 0; i < k; i++) update(i, 1), Q.emplace(col[i], i);
    for(int i = 0; i < n; i++) {
        if(query(C[i]) - query(C[i] - 1) == 1)
            for(int j = 0; j < 15; j++) WriteAdvice(0);
        else {
            pii now = Q.top(); Q.pop();
            col[now.y] = lower_bound(C + i + 1, C + n, now.y) - C;
            int idx = query(now.y); 
            for(int j = 0; j < 15; j++) WriteAdvice(idx >> j & 1);
            col[C[i]] = lower_bound(C + i + 1, C + n, C[i]) - C;
            Q.emplace(col[C[i]], C[i]);
        }
    }
}
#include "assistant.h"
#include <bits/stdc++.h>

using namespace std;

static const int N = 1e5 + 5;

static int t[N];

static void update(int x, int k) {
    for(int i = x + 1; i < N; i += i & -i)
        t[i] += k;
}

static int query(int x, int ret = 0) {
    for(int i = x + 1; i; i -= i & -i)
        ret += t[i];
    return ret;
}

void Assist(unsigned char *A, int n, int k, int R) {
    for(int i = 0; i < k; i++) update(i, 1);
    for(int i = 0; i < n; i++) {
        int now = GetRequest();
        if(query(now) - query(now - 1) == 1) continue;
        
        int idx = 0;
        for(int j = 15 * i; j < 15 * (i + 1); j++)
            if(A[j] == 1) idx += (1 << (j - 15 * i));
        
        int l = 0, r = n - 1;
        while(l < r) {
            int mid = (l + r) >> 1;
            if(query(mid) >= idx) r = mid;
            else l = mid + 1;
        }

        PutBack(r);
        update(r, -1), update(now, 1);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 776 KB Output is correct
2 Incorrect 2 ms 868 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 2224 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 321 ms 11584 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 944 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 410 ms 14072 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 403 ms 14472 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 399 ms 14012 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 407 ms 14344 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 399 ms 14364 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 390 ms 13996 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 427 ms 14420 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 455 ms 13932 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 447 ms 13992 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 515 ms 14224 KB Error - Putting back a color that is not on the scaffold