답안 #152978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152978 2019-09-11T03:06:18 Z qkxwsm 최후의 만찬 (IOI12_supper) C++14
100 / 100
185 ms 9632 KB
#include "advisor.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define MAXN 1000013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int pos[MAXN];
int rt[MAXN];
bitset<MAXN> important;
set<pii> stor;

void ComputeAdvice(int *C, int N, int K, int M)
{
	//some guys you get are "useless", some guys are not
	//decide which ones are important and which arent.
	FOR(i, 0, N) pos[i] = N;
	FORD(i, N, 0)
	{
		int x = C[i];
		rt[i] = pos[x];
		pos[x] = i;
	}
	FOR(i, 0, K)
	{
		stor.insert({pos[i] + K, i});
		// cerr << "INSERT " << pos[i] + K << ',' << i << endl;
		pos[i] = i;
	}
	FOR(i, 0, N)
	{
		int x = C[i];
		if (stor.find({i + K, x}) != stor.end())
		{
			important[pos[x]] = true;
			stor.erase({i + K, x});
		}
		else
		{
			stor.erase(prev(stor.end()));
		}
		pos[x] = i + K;
		// cerr << "POS " << x << " = " << i + K << endl;
		stor.insert({rt[i] + K, x});
	}
	FOR(i, 0, N + K)
	{
		// cerr << important[i] << ' ';
		WriteAdvice((important[i] ? 1 : 0));
	}
	// cerr << endl;
}
#include "assistant.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define MAXN 1000013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

set<int> useful, useless;

void Assist(unsigned char *A, int N, int K, int R)
{
	FOR(i, 0, K)
	{
		if (A[i])
		{
			useful.insert(i);
		}
		else
		{
			useless.insert(i);
		}
	}
	FOR(i, K, K + N)
	{
		int cur = GetRequest();
		if (useful.find(cur) == useful.end())
		{
			int x = *useless.begin();
			useless.erase(useless.begin());
			PutBack(x);
		}
		else
		{
			useful.erase(cur);
		}
		if (A[i])
		{
			useful.insert(cur);
		}
		else
		{
			useless.insert(cur);
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 840 KB Output is correct
2 Correct 4 ms 876 KB Output is correct
3 Correct 6 ms 892 KB Output is correct
4 Correct 6 ms 916 KB Output is correct
5 Correct 7 ms 816 KB Output is correct
6 Correct 8 ms 1068 KB Output is correct
7 Correct 9 ms 1076 KB Output is correct
8 Correct 8 ms 1144 KB Output is correct
9 Correct 8 ms 1008 KB Output is correct
10 Correct 11 ms 1452 KB Output is correct
11 Correct 10 ms 1104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1384 KB Output is correct
2 Correct 65 ms 3776 KB Output is correct
3 Correct 168 ms 9632 KB Output is correct
4 Correct 78 ms 5872 KB Output is correct
5 Correct 88 ms 6128 KB Output is correct
6 Correct 119 ms 6664 KB Output is correct
7 Correct 157 ms 7872 KB Output is correct
8 Correct 112 ms 7664 KB Output is correct
9 Correct 74 ms 5872 KB Output is correct
10 Correct 179 ms 8960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 131 ms 6896 KB Output is correct
2 Correct 177 ms 8432 KB Output is correct
3 Correct 185 ms 8432 KB Output is correct
4 Correct 184 ms 8376 KB Output is correct
5 Correct 179 ms 7920 KB Output is correct
6 Correct 179 ms 8488 KB Output is correct
7 Correct 170 ms 8432 KB Output is correct
8 Correct 128 ms 8432 KB Output is correct
9 Correct 164 ms 8456 KB Output is correct
10 Correct 168 ms 8432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1068 KB Output is correct
2 Correct 9 ms 1132 KB Output is correct
3 Correct 7 ms 1008 KB Output is correct
4 Correct 7 ms 940 KB Output is correct
5 Correct 8 ms 944 KB Output is correct
6 Correct 8 ms 1076 KB Output is correct
7 Correct 9 ms 1008 KB Output is correct
8 Correct 10 ms 1108 KB Output is correct
9 Correct 10 ms 1068 KB Output is correct
10 Correct 12 ms 1332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 7920 KB Output is correct - 120000 bits used
2 Correct 161 ms 8176 KB Output is correct - 122000 bits used
3 Correct 168 ms 8688 KB Output is correct - 125000 bits used
4 Correct 167 ms 8432 KB Output is correct - 125000 bits used
5 Correct 169 ms 8424 KB Output is correct - 125000 bits used
6 Correct 167 ms 8432 KB Output is correct - 125000 bits used
7 Correct 170 ms 8432 KB Output is correct - 124828 bits used
8 Correct 182 ms 8432 KB Output is correct - 124910 bits used
9 Correct 169 ms 8688 KB Output is correct - 125000 bits used
10 Correct 136 ms 8776 KB Output is correct - 125000 bits used