답안 #995851

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995851 2024-06-10T02:38:57 Z vjudge1 사육제 (CEOI14_carnival) C++17
100 / 100
5 ms 488 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#pragma GCC target("avx,avx2,fma")
#define ll long long
#define pb push_back
#define pu push
#define ins insert
#define bruh ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ff(x,a,b,c) for (auto x=a;x<=b;x+=c)
#define fd(x,a,b,c) for (auto x=a;x>=b;x-=c)
#define int ll

using namespace std;

const int N = 1e6+5;
const int mod = 1e9+7;
int power(int a,int b) {ll x = 1;if (a >= mod) a%=mod; while (b) {if (b & 1) x = x*a % mod;a = a*a % mod;b>>=1;}return x;} 

int ask(vector<int> a)
{
	cout<<a.size()<<" ";
	for (auto i : a) cout<<i<<" ";
	cout<<endl; fflush(stdout);
	int ans; cin>>ans; return ans;
}

void solve()
{
	int n;
	cin>>n;
	vector<int> ans(n+1); ans[1] = 1;
	vector<int> cur; cur.pb(1);
	for (int i=2;i<=n;i++)
	{
		vector<int> tmp = cur; tmp.pb(i); int x = ask(tmp);
		if (x==cur.size()+1) cur.pb(i),ans[i] = cur.size();
		else 
		{
			int l = 0,r = cur.size()-1,res = -1;
			while (l<=r)
			{
				int mid = l+(r-l)/2;
				cout<<mid-l+2<<" ";
				for (int j=l;j<=mid;j++) cout<<cur[j]<<" ";
				cout<<i<<endl;
				fflush(stdout); int m; cin>>m;
				if (m==mid-l+1) res = mid,r = mid-1;
				else l = mid+1;
			}
			ans[i] = ans[cur[res]];
		}
	}
	cout<<0<<" ";
	for (int i=1;i<=n;i++) cout<<ans[i]<<" ";
}

signed main()
{
	bruh
	int t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
		cout<<"\n";
	}
}

Compilation message

carnival.cpp: In function 'void solve()':
carnival.cpp:37:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   if (x==cur.size()+1) cur.pb(i),ans[i] = cur.size();
      |       ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 3 ms 464 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct