답안 #256261

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256261 2020-08-02T12:42:05 Z Akashi 최후의 만찬 (IOI12_supper) C++14
61 / 100
468 ms 18904 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {

    vector <int> ap(N, N);
    vector <int> Next(N, N);
    for (int i = N - 1; i >= 0 ; --i) {
        Next[i] = ap[C[i]];
        ap[C[i]] = i;
    }

    vector <bool> adv(M, 1);

    set <pair <int, int> > s;
    vector <bool> f(N, 0);

    for (int i = 0; i < K ; ++i) {
        s.insert({ap[i], i});
        f[i] = 1;
    }

    for (int i = 0; i < N ; ++i) {
        if (f[C[i]] == 1) {
            set <pair <int, int> > :: iterator it = s.lower_bound({i, 0});
            s.erase(it);
        } else {
            ///trebuie sa scot o culoare de pe paleta
            set <pair <int, int> > :: reverse_iterator it = s.rbegin();
            adv[it->second] = 0;
            if (it->second < K) f[it->second] = 0;
            else f[C[it->second - K]] = 0;
            s.erase(*it);
        }

        f[C[i]] = 1;
        s.insert({Next[i], i + K});
    }

    for (auto it : adv) WriteAdvice(it);

    return ;
}

#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;

void Assist(unsigned char *A, int N, int K, int R) {
    vector <bool> f(N, 0);
    vector <int> rec;

    int ind = 0;
    for (int i = 0; i < K ; ++i, ++ind) {
        if (A[ind] == 0) rec.push_back(i);
        f[i] = 1;
    }

    for (int i = 0; i < N ; ++i, ++ind) {
        int req = GetRequest();
        if (!f[req]) {
            f[req] = 1;
            f[rec.back()] = 0;
            PutBack(rec.back());
            rec.pop_back();
        }

        if (A[ind] == 0) rec.push_back(req);
    }

    return ;
}
/**
4 2 65000
2 0 3 0
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1228 KB Output is correct
2 Correct 13 ms 1028 KB Output is correct
3 Correct 14 ms 1172 KB Output is correct
4 Correct 15 ms 1044 KB Output is correct
5 Correct 18 ms 1424 KB Output is correct
6 Correct 16 ms 1280 KB Output is correct
7 Correct 17 ms 1400 KB Output is correct
8 Correct 21 ms 1376 KB Output is correct
9 Correct 17 ms 1388 KB Output is correct
10 Correct 16 ms 1596 KB Output is correct
11 Correct 16 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 399 ms 13068 KB Output is correct
2 Correct 414 ms 14792 KB Output is correct
3 Correct 468 ms 18904 KB Output is correct
4 Correct 434 ms 15920 KB Output is correct
5 Correct 454 ms 16352 KB Output is correct
6 Correct 455 ms 16404 KB Output is correct
7 Correct 463 ms 17632 KB Output is correct
8 Correct 440 ms 18128 KB Output is correct
9 Correct 444 ms 16040 KB Output is correct
10 Correct 463 ms 18584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 366 ms 12944 KB Output is correct
2 Correct 361 ms 13920 KB Output is correct
3 Correct 365 ms 13904 KB Output is correct
4 Correct 373 ms 13920 KB Output is correct
5 Correct 364 ms 13640 KB Output is correct
6 Correct 362 ms 15448 KB Output is correct
7 Correct 371 ms 15200 KB Output is correct
8 Correct 362 ms 15200 KB Output is correct
9 Correct 357 ms 15456 KB Output is correct
10 Correct 365 ms 15200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1024 KB Output is correct
2 Correct 6 ms 1168 KB Output is correct
3 Correct 5 ms 964 KB Output is correct
4 Correct 5 ms 816 KB Output is correct
5 Correct 5 ms 1228 KB Output is correct
6 Correct 6 ms 1280 KB Output is correct
7 Correct 7 ms 1364 KB Output is correct
8 Correct 6 ms 1196 KB Output is correct
9 Correct 6 ms 1180 KB Output is correct
10 Correct 7 ms 1304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 415 ms 15128 KB Output is partially correct - 1800000 bits used
2 Correct 413 ms 15632 KB Output is partially correct - 1800000 bits used
3 Correct 436 ms 15640 KB Output is partially correct - 1800000 bits used
4 Correct 437 ms 15896 KB Output is partially correct - 1800000 bits used
5 Correct 424 ms 15888 KB Output is partially correct - 1800000 bits used
6 Correct 413 ms 15632 KB Output is partially correct - 1800000 bits used
7 Correct 422 ms 15896 KB Output is partially correct - 1800000 bits used
8 Correct 417 ms 15888 KB Output is partially correct - 1800000 bits used
9 Correct 415 ms 15640 KB Output is partially correct - 1800000 bits used
10 Correct 414 ms 15664 KB Output is partially correct - 1800000 bits used