답안 #1097027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097027 2024-10-05T19:59:26 Z idiotcomputer 최후의 만찬 (IOI12_supper) C++11
100 / 100
72 ms 10904 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) (int) (x).size()
#define pii pair<int,int>
#define f first
#define s second 

void ComputeAdvice(int *C, int N, int K, int M){
	int last[N];
	int cnext[N];
	for (int i = 0; i < N; i++) last[i] = N;
	for (int i = N-1; i >= 0; i--){
		cnext[i] = last[C[i]];
		last[C[i]] = i;
	}
	bool vis[N];
	memset(vis,0,sizeof(vis));
	set<pii> all;
	int cidx[N];
	for (int i = 0; i < K; i++){ all.insert((pii) {-last[i],i}); vis[i] = 1; cidx[i] = i;}

	bool res[N+K];
	memset(res,0,sizeof(res));
	int c,t;
	for (int i = 0; i < N; i++){
		c = C[i];
		if (vis[c]){
			res[cidx[c]] = 1;
			cidx[c] = i+K;
			all.erase((pii) {i,c});
			all.insert((pii) {-cnext[i],c});
			continue;
		}
		cidx[c] = i+K;
		t = (*all.begin()).s;
		vis[t] = 0;
		vis[c] = 1;
		all.erase(all.begin());
		all.insert((pii) {-cnext[i],c});
	}
	for (int i = 0; i < N+K; i++) WriteAdvice(res[i]);
	return;
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) (int) (x).size()
#define pii pair<int,int>
#define f first
#define s second
 
 

void Assist(unsigned char *A, int N, int K, int R){
	stack<int> o;
	bool vis[N];
	memset(vis,0,sizeof(vis));
	for (int i = 0; i < K; i++){
		vis[i] = 1;
		if (A[i] == 0) o.push(i);
	}

	int c,t;
	for (int i = 0; i < N; i++){
		c = GetRequest();
		if (vis[c]){
			if (A[i+K] == 0) o.push(c);
			continue;
		}
		t = o.top();
		o.pop(); 	
		vis[t] = 0;
		PutBack(t);
		vis[c] = 1;
		if (A[i+K] == 0) o.push(c);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 784 KB Output is correct
2 Correct 0 ms 784 KB Output is correct
3 Correct 1 ms 844 KB Output is correct
4 Correct 2 ms 820 KB Output is correct
5 Correct 2 ms 840 KB Output is correct
6 Correct 3 ms 1096 KB Output is correct
7 Correct 3 ms 1096 KB Output is correct
8 Correct 3 ms 1104 KB Output is correct
9 Correct 3 ms 1096 KB Output is correct
10 Correct 3 ms 1108 KB Output is correct
11 Correct 3 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1440 KB Output is correct
2 Correct 26 ms 4816 KB Output is correct
3 Correct 63 ms 9812 KB Output is correct
4 Correct 46 ms 6272 KB Output is correct
5 Correct 37 ms 6516 KB Output is correct
6 Correct 44 ms 7732 KB Output is correct
7 Correct 60 ms 9216 KB Output is correct
8 Correct 44 ms 7788 KB Output is correct
9 Correct 36 ms 6132 KB Output is correct
10 Correct 65 ms 10332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 7832 KB Output is correct
2 Correct 62 ms 9764 KB Output is correct
3 Correct 65 ms 9808 KB Output is correct
4 Correct 65 ms 10016 KB Output is correct
5 Correct 64 ms 10244 KB Output is correct
6 Correct 62 ms 9792 KB Output is correct
7 Correct 65 ms 10048 KB Output is correct
8 Correct 49 ms 8620 KB Output is correct
9 Correct 55 ms 10904 KB Output is correct
10 Correct 72 ms 9700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1092 KB Output is correct
2 Correct 3 ms 1096 KB Output is correct
3 Correct 2 ms 840 KB Output is correct
4 Correct 3 ms 832 KB Output is correct
5 Correct 3 ms 1096 KB Output is correct
6 Correct 3 ms 1096 KB Output is correct
7 Correct 3 ms 1092 KB Output is correct
8 Correct 3 ms 1104 KB Output is correct
9 Correct 4 ms 1096 KB Output is correct
10 Correct 4 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 9416 KB Output is correct - 120000 bits used
2 Correct 59 ms 9524 KB Output is correct - 122000 bits used
3 Correct 62 ms 9788 KB Output is correct - 125000 bits used
4 Correct 61 ms 9880 KB Output is correct - 125000 bits used
5 Correct 62 ms 9788 KB Output is correct - 125000 bits used
6 Correct 70 ms 9784 KB Output is correct - 125000 bits used
7 Correct 61 ms 9788 KB Output is correct - 124828 bits used
8 Correct 61 ms 9784 KB Output is correct - 124910 bits used
9 Correct 60 ms 9788 KB Output is correct - 125000 bits used
10 Correct 48 ms 8496 KB Output is correct - 125000 bits used