답안 #382803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
382803 2021-03-28T08:34:12 Z alireza_kaviani 최후의 만찬 (IOI12_supper) C++11
100 / 100
210 ms 16344 KB
#include <bits/stdc++.h>
#include "advisor.h"

using namespace std;

typedef pair<int, int> pii;

#define X			first
#define Y			second

const int MAXN = 2e5 + 10;
const int MOD = 1e9 + 7;

int mark[MAXN] , res[MAXN];
vector<int> vec[MAXN];
set<pii , greater<pii>> st;

void ComputeAdvice(int *C, int N, int K, int M) {
	for(int i = 0 ; i < N ; i++)	vec[i].push_back(MAXN);
	for(int i = N - 1 ; i >= 0 ; i--){
		vec[C[i]].push_back(i);
	}
	for(int i = 0 ; i < K ; i++){
		st.insert({vec[i].back() , i});
	}
	for(int i = 0 ; i < N ; i++){
		auto it = st.lower_bound({i , MOD});
		if(it != st.end() && (*it).X == i){
			res[(*it).Y] = 1;
			st.erase(it);
			vec[C[i]].pop_back();
			st.insert({vec[C[i]].back() , i + K});
		}
		else{
			st.erase(st.begin());
			vec[C[i]].pop_back();
			st.insert({vec[C[i]].back() , i + K});
		}
	}
	for(int i = 0 ; i < N + K ; i++)	WriteAdvice(res[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"

using namespace std;

#define sep			' '

set<int> st0 , st1;

void Assist(unsigned char *A, int N, int K, int R) {
	for(int i = 0 ; i < K ; i++){
//		cout << i << sep << (int)A[i] << endl;
		if(A[i] == 0)	st0.insert(i);
		else	st1.insert(i);
	}
	for(int i = 0 ; i < N ; i++){
		int cur = GetRequest();
		st0.erase(cur);
		st1.erase(cur);
//		cout << i + K << sep << (int)A[i + K] << endl;
		if(st0.size() + st1.size() == K - 1){
			if(A[i + K] == 0)	st0.insert(cur);
			if(A[i + K] == 1)	st1.insert(cur);
			continue;
		}
		PutBack((*st0.begin()));
//		cout << i << ' ' << (*st0.begin()) << endl;
		st0.erase(st0.begin());
		if(A[i + K] == 0)	st0.insert(cur);
		if(A[i + K] == 1)	st1.insert(cur);
	}
}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:21:30: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |   if(st0.size() + st1.size() == K - 1){
      |      ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 5496 KB Output is correct
2 Correct 5 ms 5348 KB Output is correct
3 Correct 7 ms 5652 KB Output is correct
4 Correct 8 ms 5848 KB Output is correct
5 Correct 8 ms 5820 KB Output is correct
6 Correct 10 ms 5808 KB Output is correct
7 Correct 12 ms 6060 KB Output is correct
8 Correct 10 ms 5936 KB Output is correct
9 Correct 10 ms 5808 KB Output is correct
10 Correct 12 ms 6024 KB Output is correct
11 Correct 12 ms 5936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 6392 KB Output is correct
2 Correct 72 ms 9916 KB Output is correct
3 Correct 189 ms 16144 KB Output is correct
4 Correct 106 ms 13116 KB Output is correct
5 Correct 113 ms 12872 KB Output is correct
6 Correct 142 ms 13760 KB Output is correct
7 Correct 172 ms 14836 KB Output is correct
8 Correct 131 ms 14120 KB Output is correct
9 Correct 90 ms 13364 KB Output is correct
10 Correct 203 ms 16236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 138 ms 12588 KB Output is correct
2 Correct 210 ms 14304 KB Output is correct
3 Correct 187 ms 14424 KB Output is correct
4 Correct 191 ms 14524 KB Output is correct
5 Correct 186 ms 13996 KB Output is correct
6 Correct 189 ms 15716 KB Output is correct
7 Correct 185 ms 15644 KB Output is correct
8 Correct 156 ms 15320 KB Output is correct
9 Correct 160 ms 16344 KB Output is correct
10 Correct 184 ms 15708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 5776 KB Output is correct
2 Correct 13 ms 6024 KB Output is correct
3 Correct 8 ms 5808 KB Output is correct
4 Correct 9 ms 6056 KB Output is correct
5 Correct 10 ms 6304 KB Output is correct
6 Correct 10 ms 5808 KB Output is correct
7 Correct 11 ms 6020 KB Output is correct
8 Correct 12 ms 5808 KB Output is correct
9 Correct 12 ms 5936 KB Output is correct
10 Correct 13 ms 6252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 173 ms 13876 KB Output is correct - 120000 bits used
2 Correct 186 ms 14008 KB Output is correct - 122000 bits used
3 Correct 204 ms 14496 KB Output is correct - 125000 bits used
4 Correct 191 ms 14716 KB Output is correct - 125000 bits used
5 Correct 192 ms 14268 KB Output is correct - 125000 bits used
6 Correct 190 ms 14540 KB Output is correct - 125000 bits used
7 Correct 188 ms 14652 KB Output is correct - 124828 bits used
8 Correct 188 ms 14444 KB Output is correct - 124910 bits used
9 Correct 186 ms 14600 KB Output is correct - 125000 bits used
10 Correct 157 ms 14160 KB Output is correct - 125000 bits used