답안 #1012915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012915 2024-07-02T19:57:24 Z Tob 최후의 만찬 (IOI12_supper) C++14
100 / 100
158 ms 19284 KB
#include <bits/stdc++.h>

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;


#include "advisor.h"
#include "assistant.h"

void ComputeAdvice(int *c, int n, int k, int m) {
	vector <vector <int> > ne(n), del(n);
	for (int i = 0; i < n; i++) {
		ne[c[i]].pb(i);
	}
	for (int i = 0; i < n; i++) ne[i].pb(n);
	set <pii> s;
	for (int i = 0; i < k; i++) s.insert({*ne[i].begin(), i});
	for (int i = 0; i < n; i++) {
		int x = c[i];
		if (s.find({i, x}) != s.end()) s.erase({i, x});
		else {
			int y = (--s.end()) -> S;
			s.erase(--s.end());
			del[y].pb(i);
		}
		s.insert({*upper_bound(all(ne[x]), i), x});
	}
	vector <int> res(n+k, 0);
	for (int i = 0; i < n; i++) del[i].pb(n+1);
	for (int i = 0; i < k; i++) {
		res[i] = (*del[i].begin() > *ne[i].begin());
	}
	for (int i = 0; i < n; i++) {
		res[k+i] = (*upper_bound(all(del[c[i]]), i) > *upper_bound(all(ne[c[i]]), i));
	}
	for (int i = 0; i < n+k; i++) {
		WriteAdvice(res[i]);
	}
}
#include <bits/stdc++.h>

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;


#include "advisor.h"
#include "assistant.h"

void Assist(unsigned char *a, int n, int k, int r) {
	set <int> s, t;
	for (int i = 0; i < k; i++) {
		s.insert(i);
		if (!a[i]) t.insert(i);
	}
	for (int i = 0; i < n; i++) {
		int x = GetRequest();
		if (s.find(x) == s.end()) {
			int y = *t.begin();
			s.erase(y);
			t.erase(y);
			s.insert(x);
			PutBack(y);
		}
		if (!a[k+i]) t.insert(x);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 784 KB Output is correct
2 Correct 1 ms 800 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 3 ms 1080 KB Output is correct
5 Correct 3 ms 1448 KB Output is correct
6 Correct 4 ms 1364 KB Output is correct
7 Correct 4 ms 1576 KB Output is correct
8 Correct 4 ms 1616 KB Output is correct
9 Correct 6 ms 1728 KB Output is correct
10 Correct 5 ms 1616 KB Output is correct
11 Correct 6 ms 1456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 2456 KB Output is correct
2 Correct 49 ms 8552 KB Output is correct
3 Correct 120 ms 19284 KB Output is correct
4 Correct 86 ms 14932 KB Output is correct
5 Correct 86 ms 15116 KB Output is correct
6 Correct 96 ms 15892 KB Output is correct
7 Correct 123 ms 17720 KB Output is correct
8 Correct 89 ms 15468 KB Output is correct
9 Correct 65 ms 15864 KB Output is correct
10 Correct 119 ms 18940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 14624 KB Output is correct
2 Correct 135 ms 18236 KB Output is correct
3 Correct 150 ms 18340 KB Output is correct
4 Correct 148 ms 18312 KB Output is correct
5 Correct 142 ms 17956 KB Output is correct
6 Correct 150 ms 18240 KB Output is correct
7 Correct 109 ms 18572 KB Output is correct
8 Correct 120 ms 18076 KB Output is correct
9 Correct 92 ms 19196 KB Output is correct
10 Correct 122 ms 18344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1460 KB Output is correct
2 Correct 5 ms 1616 KB Output is correct
3 Correct 5 ms 1588 KB Output is correct
4 Correct 4 ms 1352 KB Output is correct
5 Correct 8 ms 1352 KB Output is correct
6 Correct 5 ms 1356 KB Output is correct
7 Correct 6 ms 1608 KB Output is correct
8 Correct 5 ms 1612 KB Output is correct
9 Correct 4 ms 1608 KB Output is correct
10 Correct 5 ms 1872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 125 ms 17904 KB Output is correct - 120000 bits used
2 Correct 120 ms 18008 KB Output is correct - 122000 bits used
3 Correct 135 ms 18168 KB Output is correct - 125000 bits used
4 Correct 158 ms 18268 KB Output is correct - 125000 bits used
5 Correct 117 ms 18200 KB Output is correct - 125000 bits used
6 Correct 136 ms 18436 KB Output is correct - 125000 bits used
7 Correct 117 ms 18368 KB Output is correct - 124828 bits used
8 Correct 126 ms 18252 KB Output is correct - 124910 bits used
9 Correct 156 ms 18220 KB Output is correct - 125000 bits used
10 Correct 125 ms 17968 KB Output is correct - 125000 bits used