답안 #754354

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754354 2023-06-07T14:30:20 Z lukameladze 최후의 만찬 (IOI12_supper) C++17
100 / 100
239 ms 12760 KB
# include "advisor.h"
# include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pii pair <int, int>
#define pb push_back
const int MX = 3e5 + 5;
int n,k,m,c[MX],lst[MX], nxt[MX], j_del[MX];
set <int> cur;
set <pii> pot;
void ComputeAdvice(int *C, int N, int K, int M) {
    n = N; k = K; m = M;
    for (int i = 0; i < n + k; i++) {
        if (i < k) {
            c[i] = i;
        } else c[i] = C[i - k];
    }
    for (int i = 0; i < n; i++) {
        lst[i] = n + k + 1;
    }
    for (int i = n + k - 1; i >= 0; i--) {
        nxt[i] = lst[c[i]];
        lst[c[i]] = i;
    }
    for (int i = 0; i < n; i++) lst[i] = -1;
    for (int i = 0; i <= n + k - 1; i++) {
        if (cur.count(c[i])) {
            pot.erase({i, c[i]});
            pot.insert({nxt[i], c[i]});
        } else {
            if (cur.size() != k) {
                pot.insert({nxt[i], c[i]});
                cur.insert(c[i]);
            } else {
                auto it = --pot.end();
                int col = (*it).s;
                j_del[lst[col]] = 1; // imis washla nebismier dros shemidzlia
                pot.erase(it); cur.erase(col);
                pot.insert({nxt[i], c[i]}); cur.insert(c[i]);
            }
        }
        lst[c[i]] = i;
    }
    for (int i = 0; i < n + k; i++) {
        WriteAdvice(j_del[i]);
    }
}
#include "assistant.h"
# include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pii pair <int, int>
#define pb push_back

void Assist(unsigned char *A, int N, int K, int R) {
    int n = N, k = K, r = R;
    vector <int> j_del, pre; pre = j_del = vector <int> (n + k, 0);
    set <int> cur, to_del;
    for (int i = 0; i < r; i++) {
        j_del[i] = A[i];
    }
    for (int i = 0; i < n; i++) pre[i] = -1;
    for (int i = 0; i < n + k; i++) {
        int to_add = (i < k ? i : GetRequest());
        if (cur.count(to_add) || cur.size() < k) {
            if (pre[to_add] != -1 && j_del[pre[to_add]]) to_del.erase(to_add);
            if (j_del[i]) to_del.insert(to_add);
            cur.insert(to_add);
        } else {
            auto it = to_del.begin(); int x = (*it);
            PutBack(x);
            to_del.erase(x); cur.erase(x); cur.insert(to_add);
            if (j_del[i]) to_del.insert(to_add);
        }
        pre[to_add] = i;
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:32:28: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |             if (cur.size() != k) {
      |                 ~~~~~~~~~~~^~~~

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:19:45: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |         if (cur.count(to_add) || cur.size() < k) {
      |                                  ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 524 KB Output is correct
2 Correct 1 ms 656 KB Output is correct
3 Correct 2 ms 908 KB Output is correct
4 Correct 3 ms 660 KB Output is correct
5 Correct 5 ms 956 KB Output is correct
6 Correct 5 ms 956 KB Output is correct
7 Correct 5 ms 944 KB Output is correct
8 Correct 6 ms 1072 KB Output is correct
9 Correct 7 ms 964 KB Output is correct
10 Correct 7 ms 1220 KB Output is correct
11 Correct 7 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1552 KB Output is correct
2 Correct 60 ms 4452 KB Output is correct
3 Correct 159 ms 12760 KB Output is correct
4 Correct 92 ms 6780 KB Output is correct
5 Correct 98 ms 6880 KB Output is correct
6 Correct 136 ms 7832 KB Output is correct
7 Correct 187 ms 10352 KB Output is correct
8 Correct 135 ms 9668 KB Output is correct
9 Correct 73 ms 6616 KB Output is correct
10 Correct 239 ms 11812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 9128 KB Output is correct
2 Correct 157 ms 10956 KB Output is correct
3 Correct 164 ms 11240 KB Output is correct
4 Correct 167 ms 11352 KB Output is correct
5 Correct 152 ms 10624 KB Output is correct
6 Correct 187 ms 11300 KB Output is correct
7 Correct 168 ms 11228 KB Output is correct
8 Correct 147 ms 10784 KB Output is correct
9 Correct 152 ms 11676 KB Output is correct
10 Correct 159 ms 11320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1060 KB Output is correct
2 Correct 5 ms 1072 KB Output is correct
3 Correct 5 ms 964 KB Output is correct
4 Correct 5 ms 956 KB Output is correct
5 Correct 5 ms 964 KB Output is correct
6 Correct 6 ms 940 KB Output is correct
7 Correct 7 ms 960 KB Output is correct
8 Correct 7 ms 1088 KB Output is correct
9 Correct 7 ms 1096 KB Output is correct
10 Correct 10 ms 1464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 160 ms 10428 KB Output is correct - 120000 bits used
2 Correct 181 ms 10652 KB Output is correct - 122000 bits used
3 Correct 177 ms 11260 KB Output is correct - 125000 bits used
4 Correct 161 ms 11176 KB Output is correct - 125000 bits used
5 Correct 166 ms 11272 KB Output is correct - 125000 bits used
6 Correct 179 ms 11208 KB Output is correct - 125000 bits used
7 Correct 173 ms 11596 KB Output is correct - 124828 bits used
8 Correct 162 ms 11168 KB Output is correct - 124910 bits used
9 Correct 163 ms 11168 KB Output is correct - 125000 bits used
10 Correct 146 ms 10884 KB Output is correct - 125000 bits used