답안 #51909

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51909 2018-06-22T16:03:56 Z rondojim 최후의 만찬 (IOI12_supper) C++17
100 / 100
165 ms 50560 KB
#include "advisor.h"
#include <bits/stdc++.h>
 
using namespace std;

typedef long long ll;
 
const int MAXN = 1e5 + 5;
vector<bool> used(MAXN, 0);
int nxt[MAXN], pos[MAXN], top[MAXN];
 
struct col{
	int color, next;
	bool operator<(const col &x) const {
		return next < x.next;
	}
};
 
priority_queue<col> pq;
vector<int> work[MAXN];

void ComputeAdvice(int *c, int n, int k, int m){
	for(int i=0; i<n; ++i) pos[i] = -1, nxt[i] = n;
	for(int i=0; i<n; ++i){
		if(pos[c[i]] == -1){
			pos[c[i]] = i;
			if(c[i] < k) pq.push({c[i], i});
		}
		else{
			nxt[pos[c[i]]] = i;
			pos[c[i]] = i;
		}
	}
	for(int i=0; i<n; ++i){
		if(pos[i] == -1){
			if(i < k) pq.push({i, n});
		}
		else nxt[pos[i]] = n;
	}
	for(int i=0; i<k; ++i) used[i] = true;
	for(int i=0; i<n; ++i){
		if(used[c[i]]) work[c[i]].push_back(0);
		else{
			col t = pq.top();
			pq.pop();
			used[t.color] = false;	
			used[c[i]] = true;
			work[t.color].push_back(1);
		}
		pq.push({c[i], nxt[i]});
	}
	for(int i=0; i<n+k; ++i){
		int j = i < k ? i : c[i - k];
		if(top[j] == work[j].size()) WriteAdvice(1);
		else WriteAdvice(work[j][top[j]++]);
	}
}
#include "assistant.h"
#include <vector>
 
const int MAXN = 2e5 + 5;

std::vector<bool> used(MAXN, false);
int exclude[MAXN], top, bot;

void Assist(unsigned char *advice, int n, int k, int r) {
	for(int i=0; i<k; ++i){
		used[i] = true;
		if(advice[i]) exclude[top++] = i;
	}
	advice += k;
	for(int i=0; i<n; ++i){
		int req = GetRequest();
		if(!used[req]) {
			PutBack(exclude[bot]);
			used[req] = true;
			used[exclude[bot++]] = false;
		}
		if(advice[i]) exclude[top++] = req;
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:54:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(top[j] == work[j].size()) WriteAdvice(1);
      ~~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5360 KB Output is correct
2 Correct 6 ms 5488 KB Output is correct
3 Correct 7 ms 5864 KB Output is correct
4 Correct 8 ms 6128 KB Output is correct
5 Correct 15 ms 6456 KB Output is correct
6 Correct 13 ms 6536 KB Output is correct
7 Correct 12 ms 6616 KB Output is correct
8 Correct 12 ms 6696 KB Output is correct
9 Correct 12 ms 6744 KB Output is correct
10 Correct 13 ms 6800 KB Output is correct
11 Correct 12 ms 6848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 7408 KB Output is correct
2 Correct 64 ms 11344 KB Output is correct
3 Correct 115 ms 19336 KB Output is correct
4 Correct 138 ms 19336 KB Output is correct
5 Correct 109 ms 19592 KB Output is correct
6 Correct 140 ms 21136 KB Output is correct
7 Correct 107 ms 22880 KB Output is correct
8 Correct 95 ms 23320 KB Output is correct
9 Correct 81 ms 23320 KB Output is correct
10 Correct 124 ms 26512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 26512 KB Output is correct
2 Correct 124 ms 28344 KB Output is correct
3 Correct 112 ms 29688 KB Output is correct
4 Correct 117 ms 30696 KB Output is correct
5 Correct 100 ms 31216 KB Output is correct
6 Correct 119 ms 33192 KB Output is correct
7 Correct 130 ms 34120 KB Output is correct
8 Correct 125 ms 36304 KB Output is correct
9 Correct 92 ms 36304 KB Output is correct
10 Correct 103 ms 37784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 37784 KB Output is correct
2 Correct 10 ms 37784 KB Output is correct
3 Correct 10 ms 37784 KB Output is correct
4 Correct 12 ms 37784 KB Output is correct
5 Correct 11 ms 37784 KB Output is correct
6 Correct 13 ms 37784 KB Output is correct
7 Correct 10 ms 37784 KB Output is correct
8 Correct 10 ms 37784 KB Output is correct
9 Correct 10 ms 37784 KB Output is correct
10 Correct 12 ms 37784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 39328 KB Output is correct - 120000 bits used
2 Correct 125 ms 40536 KB Output is correct - 122000 bits used
3 Correct 105 ms 41888 KB Output is correct - 125000 bits used
4 Correct 127 ms 42984 KB Output is correct - 125000 bits used
5 Correct 146 ms 44224 KB Output is correct - 125000 bits used
6 Correct 165 ms 45384 KB Output is correct - 125000 bits used
7 Correct 125 ms 46456 KB Output is correct - 124828 bits used
8 Correct 122 ms 47680 KB Output is correct - 124910 bits used
9 Correct 127 ms 48824 KB Output is correct - 125000 bits used
10 Correct 113 ms 50560 KB Output is correct - 125000 bits used