Submission #750930

# Submission time Handle Problem Language Result Execution time Memory
750930 2023-05-30T15:08:17 Z vjudge1 Carnival (CEOI14_carnival) C++14
100 / 100
11 ms 336 KB
// teddybear's code
// the one who loves NBP
// noe the second
// goal: 0 / 8
// get medal in APIO (like TKN)
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")

// prob: 
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#define FOR(i,n) for (int i = 0; i<n; i++)
using ll = long long;
using ull = unsigned long long;
ll n,m,t;
ll cnt = 0;
const int maxn = 1e5;
const ll mod = 1e9 + 7;
#define Y "YES"
#define N "NO"
int a[1005][1005];
bool visited[1005][1005];
int dist[1005][1005];
int w,h;
int fx[4] = {-1, 1, 0, 0};
int fy[4] = {0, 0, -1, 1};
queue <pair<int,int>> q;

void check()
{
	
}

void solve()
{
	cin >> n;
	set <int> st;
	vector <int> res;
	vector <int> ans(n+1);
	int tmp;
	for (int i = 1; i<=n; i++)
	{
		cout << (int)res.size() + 1 << ' ';
		for (int j = 0; j<(int)res.size(); j++)
		{
			cout << res[j] << ' ';
		}
		cout << i << '\n';
		cin >> tmp;
		int tmp2;
		if (tmp == res.size() + 1)
		{
			ans[i] = tmp;
			res.push_back(i);
		}
		
		else
		{
			int l = 0, r = res.size() - 1;
			
			if (l == r)
			{
				ans[i] = ans[1];
				continue;
			}
			
			while (l < r)
			{
				int mid = (l + r) / 2;
				
				cout << mid - l + 2 << ' ';
				for (int j = l; j<=mid; j++)
				{
					cout << res[j] << ' ';
				}
				cout << i << '\n';
				//cout << flush;
				
				cin >> tmp2;
				if (tmp2 == 1)
				{
					//res[i] = res[l];
					ans[i] = ans[res[l]];
					break;
				}
				
				if (tmp2 == mid - l + 1)
				{
					r = mid;
				}
				
				else
				{
					cout << r - mid + 1 << ' ';
					for (int j = mid + 1; j<=r; j++)
					{
						cout << res[j] << ' ';
					}
					
					cout << i << '\n';
					
					cin >> tmp2;
					if (tmp2 == 1)
					{
						ans[i] = ans[res[r]];
						break;
					}
				
					if (tmp2 == r - mid)
					{
						l = mid + 1;
					}
				}
				
			}
		}
	}
	
	cout << 0 << ' ';
	for (int i = 1; i<=n; i++)
	{
		cout << ans[i] << ' ';
	}
	return;
}

void init()
{
 	int te = 1; 
 	while (te--)
 	{
 	 	  solve();
 	}
}

void preprocess()
{

}


int main()
{
 	//ios_base::sync_with_stdio(false);
 	//cin.tie(NULL);
    //cin.tie(0); cout.tie(0);
    // 1 2 1 3 2
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
 	init();
 	preprocess();
 	//solve();
 	return 0;
}

Compilation message

carnival.cpp: In function 'void solve()':
carnival.cpp:55:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   if (tmp == res.size() + 1)
      |       ~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 3 ms 312 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Correct 5 ms 308 KB Output is correct
4 Correct 2 ms 308 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 6 ms 312 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 8 ms 312 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 8 ms 312 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 4 ms 336 KB Output is correct