답안 #152758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152758 2019-09-09T11:37:53 Z junodeveloper 사육제 (CEOI14_carnival) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n, par[151];
int T[1010];
int pn(int u){return u==par[u]?u:(par[u]=pn(par[u]));}
void us(int a,int b) {
	a=pn(a),b=pn(b);
	par[b]=a;
}
int query(int p,int l,int r) {
	printf("%d ",r-l+2);
	int i;
	printf("%d ",p);
	for(i=l;i<=r;i++) printf("%d ",i);
	fflush(stdout);
	int ret;
	scanf("%d",&ret);
	return ret;
}
void solve(int h,int l,int r) {
	if(l==r) {
		T[h]=1;
		return;
	}
	int mid=(l+r)/2;
	solve(h*2,l,mid);
	solve(h*2+1,mid+1,r);
	int i,ret;
	for(i=l;i<=mid;i++) {
		ret=query(i,mid+1,r);
		if(ret==T[h*2+1]+1) continue;
		else {
			int cur=h*2+1, tl=mid+1, tr=r;
			while(tl<tr) {
				int tmid=(tl+tr)/2;
				int tret=query(i,tl,tmid);
				if(tret==T[cur*2]+1) {
					tl=tmid+1;
					cur=cur*2+1;
				} else {
					tr=tmid;
					cur=cur*2;
				}
			}
			us(i,tl);
		}
	}
	vector<int> v;
	for(i=l;i<=r;i++)v.push_back(pn(i));
	sort(all(v));
	v.erase(unique(all(v)),v.end());
	T[h]=sz(v);
}
int main() {
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++) par[i]=i;
	solve(1,n);
	printf("0 ");
	for(i=1;i<=n;i++) printf("%d ",par[i]);
	fflush(stdout);
	return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:66:11: error: too few arguments to function 'void solve(int, int, int)'
  solve(1,n);
           ^
carnival.cpp:28:6: note: declared here
 void solve(int h,int l,int r) {
      ^~~~~
carnival.cpp: In function 'int query(int, int, int)':
carnival.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&ret);
  ~~~~~^~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:63:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~