답안 #204467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
204467 2020-02-25T20:46:13 Z staniewzki 사육제 (CEOI14_carnival) C++14
100 / 100
25 ms 376 KB
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;
 
int ask(vector<int> q) {
	cout << size(q) << " ";
	for(int x : q) cout << x + 1 << " ";
	cout << endl;
	int ret; cin >> ret;
	return ret;
}
 
vector<int> ans;
void solve(int c, vector<int> &a, int l, int r) {
	vector<int> q;
	FOR(i, l, r) q.emplace_back(a[i]);
	int ans1 = ask(q);
	q.emplace_back(a[0]);
	int ans2 = ask(q);
	if(ans1 != ans2) return;
	if(l == r) {
		ans[a[l]] = c;
		return;
	}
	int m = (l + r) / 2;
	solve(c, a, l, m);
	solve(c, a, m + 1, r);
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	int n; cin >> n;
	vector<int> a(n);
	REP(i, n) a[i] = i;
	int c = 0;
	ans.resize(n, 0);
	while(!a.empty()) {
		ans[a[0]] = ++c;
		if(size(a) > 1)
			solve(c, a, 1, size(a) - 1);
		vector<int> b;
		for(int i : a) {
			if(ans[i] == 0)
				b.emplace_back(i);
		}
		a = b;
	}
 
	cout << "0 ";
	REP(i, n) cout << ans[i] << " ";
	cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 376 KB Output is correct
2 Correct 23 ms 376 KB Output is correct
3 Correct 18 ms 248 KB Output is correct
4 Correct 10 ms 248 KB Output is correct
5 Correct 11 ms 248 KB Output is correct
6 Correct 10 ms 376 KB Output is correct
7 Correct 20 ms 252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 248 KB Output is correct
2 Correct 25 ms 248 KB Output is correct
3 Correct 13 ms 248 KB Output is correct
4 Correct 14 ms 248 KB Output is correct
5 Correct 15 ms 248 KB Output is correct
6 Correct 11 ms 248 KB Output is correct
7 Correct 20 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 252 KB Output is correct
2 Correct 16 ms 248 KB Output is correct
3 Correct 24 ms 248 KB Output is correct
4 Correct 12 ms 248 KB Output is correct
5 Correct 16 ms 248 KB Output is correct
6 Correct 11 ms 376 KB Output is correct
7 Correct 23 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 376 KB Output is correct
2 Correct 17 ms 376 KB Output is correct
3 Correct 15 ms 252 KB Output is correct
4 Correct 10 ms 248 KB Output is correct
5 Correct 13 ms 376 KB Output is correct
6 Correct 11 ms 376 KB Output is correct
7 Correct 22 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 248 KB Output is correct
2 Correct 21 ms 248 KB Output is correct
3 Correct 25 ms 248 KB Output is correct
4 Correct 20 ms 248 KB Output is correct
5 Correct 13 ms 248 KB Output is correct
6 Correct 11 ms 248 KB Output is correct
7 Correct 13 ms 248 KB Output is correct