답안 #361547

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
361547 2021-01-30T13:48:47 Z MetB 최후의 만찬 (IOI12_supper) C++14
0 / 100
160 ms 13140 KB
#include <iostream>
#include <vector>
#include <set>
#include "advisor.h"

using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {
	vector<vector<int>> last(N);
	vector<int> ans(N), ans_k(K);
	vector<int> request(N, -1);
	vector<int> ptr(N, 0), st(N);
	set<pair<int, int>> s;

	for (int i = 0; i < N; i++) {
		last[C[i]].push_back(i);
	}

	for (int i = 0; i < N; i++) {
		last[i].push_back(N);
	}

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

	for (int i = 0; i < N; i++) {
		request[C[i]] = i;
		if (!st[C[i]]) {
			int x = s.rbegin()->second;
			s.erase(s.find(*s.rbegin()));
			st[x] = 0;
			if (request[x] != -1) ans[request[x]] = 1;
			else ans_k[x] = 1;
			ptr[C[i]]++;
			s.insert({last[C[i]][ptr[C[i]]], C[i]});
		}
	}

	for (int i = 0; i < K; i++) {
		WriteAdvice(ans_k[i]);
	}

	for (int i = 0; i < N; i++) {
		WriteAdvice(ans[i]);
	}
}
#include <iostream>
#include <vector>
#include "assistant.h"

using namespace std;

void Assist(unsigned char *A, int N, int K, int R) {
	vector<int> st(N);
	vector<int> bottom_shelf;
	for (int i = 0; i < K; i++) {
		if (A[i]) bottom_shelf.push_back(i);
		st[i] = 1;
	}

	A += K;

	for (int i = 0; i < N; i++) {
		int x = GetRequest();
		if (!st[x]) {
			PutBack(bottom_shelf.back());
			bottom_shelf.pop_back();
		}
		st[x] = 1;
		if (A[i]) bottom_shelf.push_back(x);
	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 992 KB Output is correct
2 Incorrect 1 ms 872 KB Error - Not putting back color when it is not on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 1900 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 94 ms 10544 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1320 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 121 ms 12684 KB Error - Not putting back color when it is not on the scaffold
2 Incorrect 129 ms 12836 KB Error - Not putting back color when it is not on the scaffold
3 Incorrect 132 ms 12976 KB Error - Not putting back color when it is not on the scaffold
4 Incorrect 127 ms 12780 KB Error - Not putting back color when it is not on the scaffold
5 Incorrect 160 ms 13140 KB Error - Not putting back color when it is not on the scaffold
6 Incorrect 125 ms 12796 KB Error - Not putting back color when it is not on the scaffold
7 Incorrect 142 ms 12872 KB Error - Not putting back color when it is not on the scaffold
8 Incorrect 123 ms 12668 KB Error - Not putting back color when it is not on the scaffold
9 Incorrect 121 ms 12848 KB Error - Not putting back color when it is not on the scaffold
10 Incorrect 119 ms 12540 KB Error - Not putting back color when it is not on the scaffold