답안 #104381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104381 2019-04-06T06:31:30 Z hugo_pm 사육제 (CEOI14_carnival) C++17
0 / 100
14 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= b; --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)

#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second

const long long BIG = 1000000000000000000LL;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

void cpr(string s, vector<int> v)
{ int i = 0; for (char c : s) { if (c == '$') cout << v[i++]; else cout << c; } cout << '\n'; }

void cpr(string s) { cpr(s, {}); }

void solve();
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

const int borne = 155;
int coul[borne];
int jusq[borne];
vector<int> adj[borne];
int nbPart;
int nbCoul=0;

int ask(vector<int> v)
{
	int sz = v.size();
	if (sz == 0) return 0;
	cout << sz;
	form(i, sz) cout << " " << v[i]+1;
	cout << "\n" << flush;
	int rr2; cin >> rr2;
	return rr2;
}

int ask2(int l, int r)
{
	vector<int> v;
	form2(i, l, r+1) v.push_back(i);
	return ask(v);
}

void build(int x)
{
	int l = x, r = nbPart-1;
	while (l < r) {
		int m = (l+r+1) / 2;
		int nbe = m-x+1;
		if (ask2(x,m) == nbe) l = m;
		else r = m-1;
	}
	jusq[x] = r;
}

void dfs(int x, int c)
{
	coul[x] = c;
	for (int vo : adj[x]) if (coul[vo] == 0) {
		dfs(vo, c);
	}
}

void solve()
{
	cin >> nbPart;
	form(i, nbPart) build(i);
	form(i, nbPart-1) {
		if (jusq[i] < jusq[i+1]) {
			int vo = jusq[i] + 1;
			adj[i].push_back(vo);
			adj[vo].push_back(i);
		}
	}
	form(i, nbPart) if (coul[i] == 0) dfs(i, ++nbCoul);
	cout << "0";
	form(i, nbPart) cout << " " << coul[i];
	cout << "\n" << flush;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 256 KB Integer 12 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 384 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Output is correct
2 Incorrect 11 ms 256 KB Integer 9 violates the range [1, 8]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 384 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 384 KB Integer 3 violates the range [1, 2]
2 Halted 0 ms 0 KB -