답안 #498207

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498207 2021-12-24T15:32:36 Z inksamurai Drvca (COCI19_drvca) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _32bB6rn ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vector<int>;
using dq=deque<int>;
 
int main(){
_32bB6rn;
	int n;
	cin>>n;
	vi a(n);
	rep(i,n) cin>>a[i];
	sort(all(a));
	int id=-1;
	auto g=[](dq up,dq dw){
		if(!sz(up) or !sz(dw)) return;
		int diff=0;
		if(sz(up)>=2) diff=up[1]-up[0];
		crep(i,2,sz(up)){
			if(up[i]-up[i-1]!=diff){
				return;
			}
		}
		diff=0;
		if(sz(dw)>=2) diff=dw[1]-dw[0];
		crep(i,2,sz(dw)){
			if(dw[i]-dw[i-1]!=diff){
				return;
			}
		}
		if(sz(up)){
		rep(i,sz(up)){
			if(i+2<sz(up) and id!=-1){
				if(up[i]==a[id] and up[i+1]==a[id+1] and up[i+2]==a[id+2]) assert(false);
				}
			}
		}
		if(sz(dw)){
			rep(i,sz(dw)){
				if(i+2<sz(dw) and id!=-1){
					if(dw[i]==a[id] and dw[i+1]==a[id+1] and dw[i+2]==a[id+2]) assert(false);
				}
			}
		}
		cout<<sz(up)<<"\n";
		for(auto x : up){
			cout<<x<<" ";
		}
		cout<<"\n";
		cout<<sz(dw)<<"\n";
		for(auto x : dw){
			cout<<x<<" ";
		}
		cout<<"\n";
		exit(0);
	};
	auto f=[&](int i,int diff){
		dq up={a[i]},dw;
		rep(type,2){
			int j=i+(type==0?1:-1);
			while((type==0?j<n:j>=0)){
				while((type==0?j<n and a[j]-up.back()!=diff:j>=0 and up.front()-a[j]!=diff)){
					if(type==0) dw.pb(a[j]);
					else dw.push_front(a[j]);
					j=j+(type==0?1:-1);
				}
				if((type==0?j<n:j>=0)){
					if(type==0) up.pb(a[j]);
					else up.push_front(a[j]);
					int oj=(type==0?j+1:j-1);
					int cnt=0;
					while((type==0?oj<n:oj>=0)){
						if(type==0) dw.pb(a[oj]);
						else dw.push_front(a[oj]);
						oj+=(type==0?1:-1);
						cnt++;
					}
					if(type==1) g(up,dw);
					rep(_,cnt){
						if(type==0) dw.pop_back();
						else dw.pop_front();
					}
					j=j+(type==0?1:-1);
				}
			}
		}
		g(up,dw);
	};
	
	rep(i,n-1){
		if(i+2<n){
			if(a[i+1]-a[i]!=a[i+2]-a[i+1]){
				id=i;
				break;
			}
		}
	}
	f(0,a[1]-a[0]);
	dq up,dw;
	rep(_,2){
		for(int i=_;i<n;i+=2){
			if(_==0) up.pb(a[i]);
			else dw.pb(a[i]);
		}
	}
	g(up,dw);
	cout<<"-1\n";
//	
	return 0;
}

Compilation message

drvca.cpp: In lambda function:
drvca.cpp:45:22: error: 'id' is not captured
   45 |    if(i+2<sz(up) and id!=-1){
      |                      ^~
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:26:6: note: 'int id' declared here
   26 |  int id=-1;
      |      ^~
drvca.cpp:46:15: error: 'a' is not captured
   46 |     if(up[i]==a[id] and up[i+1]==a[id+1] and up[i+2]==a[id+2]) assert(false);
      |               ^
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:23:5: note: 'vi a' declared here
   23 |  vi a(n);
      |     ^
drvca.cpp:46:17: error: 'id' is not captured
   46 |     if(up[i]==a[id] and up[i+1]==a[id+1] and up[i+2]==a[id+2]) assert(false);
      |                 ^~
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:26:6: note: 'int id' declared here
   26 |  int id=-1;
      |      ^~
drvca.cpp:46:34: error: 'a' is not captured
   46 |     if(up[i]==a[id] and up[i+1]==a[id+1] and up[i+2]==a[id+2]) assert(false);
      |                                  ^
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:23:5: note: 'vi a' declared here
   23 |  vi a(n);
      |     ^
drvca.cpp:46:36: error: 'id' is not captured
   46 |     if(up[i]==a[id] and up[i+1]==a[id+1] and up[i+2]==a[id+2]) assert(false);
      |                                    ^~
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:26:6: note: 'int id' declared here
   26 |  int id=-1;
      |      ^~
drvca.cpp:46:55: error: 'a' is not captured
   46 |     if(up[i]==a[id] and up[i+1]==a[id+1] and up[i+2]==a[id+2]) assert(false);
      |                                                       ^
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:23:5: note: 'vi a' declared here
   23 |  vi a(n);
      |     ^
drvca.cpp:46:57: error: 'id' is not captured
   46 |     if(up[i]==a[id] and up[i+1]==a[id+1] and up[i+2]==a[id+2]) assert(false);
      |                                                         ^~
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:26:6: note: 'int id' declared here
   26 |  int id=-1;
      |      ^~
drvca.cpp:52:23: error: 'id' is not captured
   52 |     if(i+2<sz(dw) and id!=-1){
      |                       ^~
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:26:6: note: 'int id' declared here
   26 |  int id=-1;
      |      ^~
drvca.cpp:53:16: error: 'a' is not captured
   53 |      if(dw[i]==a[id] and dw[i+1]==a[id+1] and dw[i+2]==a[id+2]) assert(false);
      |                ^
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:23:5: note: 'vi a' declared here
   23 |  vi a(n);
      |     ^
drvca.cpp:53:18: error: 'id' is not captured
   53 |      if(dw[i]==a[id] and dw[i+1]==a[id+1] and dw[i+2]==a[id+2]) assert(false);
      |                  ^~
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:26:6: note: 'int id' declared here
   26 |  int id=-1;
      |      ^~
drvca.cpp:53:35: error: 'a' is not captured
   53 |      if(dw[i]==a[id] and dw[i+1]==a[id+1] and dw[i+2]==a[id+2]) assert(false);
      |                                   ^
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:23:5: note: 'vi a' declared here
   23 |  vi a(n);
      |     ^
drvca.cpp:53:37: error: 'id' is not captured
   53 |      if(dw[i]==a[id] and dw[i+1]==a[id+1] and dw[i+2]==a[id+2]) assert(false);
      |                                     ^~
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:26:6: note: 'int id' declared here
   26 |  int id=-1;
      |      ^~
drvca.cpp:53:56: error: 'a' is not captured
   53 |      if(dw[i]==a[id] and dw[i+1]==a[id+1] and dw[i+2]==a[id+2]) assert(false);
      |                                                        ^
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:23:5: note: 'vi a' declared here
   23 |  vi a(n);
      |     ^
drvca.cpp:53:58: error: 'id' is not captured
   53 |      if(dw[i]==a[id] and dw[i+1]==a[id+1] and dw[i+2]==a[id+2]) assert(false);
      |                                                          ^~
drvca.cpp:27:10: note: the lambda has no capture-default
   27 |  auto g=[](dq up,dq dw){
      |          ^
drvca.cpp:26:6: note: 'int id' declared here
   26 |  int id=-1;
      |      ^~