Submission #83827

# Submission time Handle Problem Language Result Execution time Memory
83827 2018-11-11T08:24:05 Z aminra Carnival (CEOI14_carnival) C++14
100 / 100
10 ms 696 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
const int MAXN = (int)1e5 + 7;
const int infint = (int)1e9;
const int MOD = (int)1e9 + 9;
const ll inf = (ll)2e18 + 2;
int n, a[MAXN], tsz = 1;
int ask(vector<int> v)
{
	cout << v.size() << " ";
	for (auto u : v)
		cout << u << " ";
	cout << endl;
	int get;
	cin >> get;
	return get;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	a[1] = tsz;
	vector<int> nws;
	nws.push_back(1);
	for (int i = 2; i <= n; i++)
	{
		nws.push_back(i);
		int t = ask(nws);
		if(t == nws.size())
		{
			a[i] = ++tsz;
			continue;
		}
		else
		{
			nws.pop_back();
			int L = -1, R = nws.size() - 1;
			while(R - L > 1)
			{
				int mid = (R + L) >> 1;
				vector<int> tmp;
				for (int i = 0; i <= mid; i++)
					tmp.push_back(nws[i]);
				tmp.push_back(i);
				int t = ask(tmp);
				if(t == tmp.size() - 1)
					R = mid;
				else
					L = mid;
			}
			a[i] = a[nws[R]];
		}
	}
	cout << 0 << " ";
	for (int i = 1; i <= n; i++)
		cout << a[i] << " ";
	cout << endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:32:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(t == nws.size())
      ~~^~~~~~~~~~~~~
carnival.cpp:49:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(t == tmp.size() - 1)
        ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 248 KB Output is correct
2 Correct 9 ms 452 KB Output is correct
3 Correct 6 ms 520 KB Output is correct
4 Correct 4 ms 520 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
6 Correct 4 ms 552 KB Output is correct
7 Correct 7 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 696 KB Output is correct
2 Correct 7 ms 696 KB Output is correct
3 Correct 4 ms 696 KB Output is correct
4 Correct 4 ms 696 KB Output is correct
5 Correct 6 ms 696 KB Output is correct
6 Correct 6 ms 696 KB Output is correct
7 Correct 4 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 696 KB Output is correct
2 Correct 6 ms 696 KB Output is correct
3 Correct 6 ms 696 KB Output is correct
4 Correct 3 ms 696 KB Output is correct
5 Correct 5 ms 696 KB Output is correct
6 Correct 4 ms 696 KB Output is correct
7 Correct 6 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 696 KB Output is correct
2 Correct 4 ms 696 KB Output is correct
3 Correct 5 ms 696 KB Output is correct
4 Correct 4 ms 696 KB Output is correct
5 Correct 7 ms 696 KB Output is correct
6 Correct 5 ms 696 KB Output is correct
7 Correct 6 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 696 KB Output is correct
2 Correct 8 ms 696 KB Output is correct
3 Correct 8 ms 696 KB Output is correct
4 Correct 6 ms 696 KB Output is correct
5 Correct 8 ms 696 KB Output is correct
6 Correct 5 ms 696 KB Output is correct
7 Correct 4 ms 696 KB Output is correct