답안 #829935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829935 2023-08-18T16:00:57 Z Blagoj 최후의 만찬 (IOI12_supper) C++17
0 / 100
328 ms 19524 KB
#include <bits/stdc++.h>
#include "advisor.h"

using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {
    queue<int> toDelete;
	unordered_map<int, int> cnt;
	set<int> s[N + 2];
	int Last[N + 2];
	for (int i = 0; i < N; i++) {
		cnt[C[i]]++;
		s[C[i]].insert(i + K);
	}
	for (int i = 0; i < K; i++) {
		Last[i] = i;
		if (!cnt[i]) toDelete.push(i);
	}
	vector<int> op(N + K);
	unordered_set<int> have;
	for (int i = 0; i < K; i++) {
		have.insert(i);
		if (!cnt[i]) op[i] = 1;
	}
	for (int i = 0; i < N; i++) {
		Last[C[i]] = i + K;
		if (have.count(C[i])) {
			cnt[C[i]]--;
			if (!cnt[C[i]]) {
				toDelete.push(C[i]);
				op[i + K] = 1;
			}
		}
		else {
			if (toDelete.size() == 0) {
				int last, position = -1;
				for (int x : have) {
					int temp = *s[x].lower_bound(i); 
					if (temp > position) {
						position = temp;
						last = x;
					}
				}
				toDelete.push(last);
				op[Last[last]] = 1;
			}
			int fr = toDelete.front();
			toDelete.pop();
			have.erase(fr);
			have.insert(C[i]);
			cnt[C[i]]--;
			if (!cnt[C[i]]) {
				toDelete.push(C[i]);
				op[i + K] = 1;
			}
		}
	}
	for (int i = 0; i < op.size(); i++) {
		WriteAdvice(op[i]);
	}
}
#include <bits/stdc++.h>
#include "assistant.h"

using namespace std;

void Assist(unsigned char *A, int N, int K, int R) {
    queue<int> toDelete;
	unordered_set<int> have;
	for (int i = 0; i < K; i++) {
		if (A[i] == 1) toDelete.push(i);
		have.insert(i);
	}
	for (int i = 0; i < N; i++) {
        int req = GetRequest();
		if (!have.count(req)) {
			PutBack(toDelete.front());
			have.erase(toDelete.front());
			toDelete.pop();
			have.insert(req);
		}
        if (A[i + K] == '1') {
			toDelete.push(req);
		}
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:58:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |  for (int i = 0; i < op.size(); i++) {
      |                  ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 516 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2268 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 57 ms 14544 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1264 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 328 ms 17368 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 81 ms 18016 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 76 ms 18144 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 76 ms 18068 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 80 ms 18128 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 74 ms 18048 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 80 ms 18052 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 77 ms 18056 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 78 ms 18092 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 217 ms 19524 KB Error - Putting back a color that is not on the scaffold