답안 #104867

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104867 2019-04-09T12:01:04 Z figter001 최후의 만찬 (IOI12_supper) C++17
0 / 100
198 ms 18240 KB
#include "advisor.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 1e5 + 50;
const int oo = 1e9;

vector<int> lst[nax];
set<pair<int,int>> st;
bool in[nax],rem[nax];
int w[nax];

void ComputeAdvice(int *C, int n, int k, int M) {
	for(int i=0;i<n;i++)
		lst[i].push_back(oo);
	for(int i=n-1;i>=0;i--)
		lst[C[i]].push_back(i);
	for(int i=0;i<k;i++){
		st.insert({-lst[i].back(),i});
		lst[i].pop_back();
		in[i] = 1;
	}

	for(int i=0;i<n;i++){
		if(in[C[i]] == 1){
			st.erase(--st.end());
			int id = C[i];
			st.insert({-lst[id].back(),id});
			lst[id].pop_back();
		}else{
			int id = st.begin()->second;
			in[id] = 0;
			in[C[i]] = 1;
			if(id < k)
				rem[id] = 1;
			st.erase(st.begin());
			lst[C[i]].pop_back();
			st.insert({-lst[C[i]].back(),C[i]});
		}
	}
	for(int i=n-1;i>=0;i--){
		w[i] = in[C[i]];
		in[C[i]] = 0;
	}
	for(int i=0;i<k;i++){
		WriteAdvice(rem[i]);
	}

	for(int i=0;i<n;i++){
		WriteAdvice(w[i]);
	}
}
#include "assistant.h"
#include "advisor.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 1e5 + 50;
const int oo = 1e9;

int inn[nax];

void Assist(unsigned char *A, int n, int k, int R) {
	int at = 0;
	vector<int> r,t;
	for(int i=0;i<k;i++){
		if(A[i] == 1){
			r.push_back(i);
		}
		inn[i] = 1;
	}
	at = k;
	for(int i=0;i<n;i++){
    	int req = GetRequest();
    	if(inn[req] == 0){
    		PutBack(r.back());
    		inn[req] = 1;
    		inn[r.back()] = 0;
    		r.pop_back();
    		if(A[at] == 0)
    			r.push_back(req);
    	}
      	at++;
  	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5376 KB Output is correct
2 Incorrect 7 ms 5376 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 6656 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 110 ms 15656 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 5888 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 169 ms 17632 KB Output isn't correct - not an optimal way
2 Incorrect 179 ms 17552 KB Output isn't correct - not an optimal way
3 Incorrect 181 ms 18160 KB Output isn't correct - not an optimal way
4 Incorrect 174 ms 17904 KB Output isn't correct - not an optimal way
5 Incorrect 162 ms 17904 KB Output isn't correct - not an optimal way
6 Incorrect 161 ms 18160 KB Output isn't correct - not an optimal way
7 Incorrect 172 ms 17904 KB Output isn't correct - not an optimal way
8 Incorrect 188 ms 18240 KB Output isn't correct - not an optimal way
9 Incorrect 141 ms 17904 KB Output isn't correct - not an optimal way
10 Incorrect 198 ms 17904 KB Output isn't correct - not an optimal way