답안 #921623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921623 2024-02-04T08:22:29 Z 8pete8 Drvca (COCI19_drvca) C++17
110 / 110
23 ms 4692 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<cassert>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset> 
#include<stack>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define pppiiii pair<pii,pii>
#define ppii pair<int,pii>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
const int mod=998244353,mxn=2e5+5,lg=30,inf=1e18,minf=-1e9,Mxn=100000,root=700;
int n,m;
void setIO(string name){		
	ios_base::sync_with_stdio(0); cin.tie(0);		
	freopen((name+".in").c_str(),"r",stdin);		
	freopen((name+".out").c_str(),"w",stdout);	
}
vector<int>v;
vector<int>all;
bool check(int a,int id){
	
	vector<int>l,r;
	l.pb(v[0]);
	int last=-1;
	for(int i=1;i<n;i++){
		if(r.size()>1&&v[i]-r.back()==last)r.pb(v[i]);
		else if(v[i]-l.back()==a)l.pb(v[i]);
		else{
			if(r.size()==1)last=v[i]-r.back();
			else if(r.size()>1)return false;
			r.pb(v[i]);
		}
	}
	if(l.size()==0&&r.size()==0)return false;
	if(l.size()==0||r.size()==0){
		if(l.size()<r.size())swap(l,r);
		r.pb(l.back());
		l.pop_back();
	}
	cout<<l.size()<<'\n';
	for(auto i:l)cout<<i<<" ";
	cout<<'\n';
	cout<<r.size()<<"\n";
	for(auto i:r)cout<<i<<" ";
	return true;
}
int32_t main(){
	//setIO("lifeguards");
	fastio
	cin>>n;
	v.resize(n);
	for(int i=0;i<n;i++)cin>>v[i];
	sort(all(v));
	int last=-1;
	for(int i=0;i<1;i++){
		for(int j=i;j<min(n,3ll);j++){
			if(check(v[j]-v[i],i))return 0;
		}
	}
	cout<<-1;
	return 0;
	//brute
}

Compilation message

drvca.cpp: In function 'int32_t main()':
drvca.cpp:75:6: warning: unused variable 'last' [-Wunused-variable]
   75 |  int last=-1;
      |      ^~~~
drvca.cpp: In function 'void setIO(std::string)':
drvca.cpp:36:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drvca.cpp:37:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 456 KB Output is correct
20 Correct 0 ms 456 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 4204 KB Output is correct
2 Correct 21 ms 4692 KB Output is correct
3 Correct 21 ms 4048 KB Output is correct
4 Correct 23 ms 4684 KB Output is correct
5 Correct 21 ms 4184 KB Output is correct
6 Correct 21 ms 4436 KB Output is correct
7 Correct 20 ms 4172 KB Output is correct
8 Correct 21 ms 4436 KB Output is correct
9 Correct 19 ms 3748 KB Output is correct
10 Correct 21 ms 4076 KB Output is correct
11 Correct 15 ms 4048 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 456 KB Output is correct
20 Correct 0 ms 456 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 452 KB Output is correct
31 Correct 21 ms 4204 KB Output is correct
32 Correct 21 ms 4692 KB Output is correct
33 Correct 21 ms 4048 KB Output is correct
34 Correct 23 ms 4684 KB Output is correct
35 Correct 21 ms 4184 KB Output is correct
36 Correct 21 ms 4436 KB Output is correct
37 Correct 20 ms 4172 KB Output is correct
38 Correct 21 ms 4436 KB Output is correct
39 Correct 19 ms 3748 KB Output is correct
40 Correct 21 ms 4076 KB Output is correct
41 Correct 15 ms 4048 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 21 ms 4020 KB Output is correct
44 Correct 15 ms 2788 KB Output is correct
45 Correct 19 ms 3900 KB Output is correct
46 Correct 21 ms 4360 KB Output is correct
47 Correct 15 ms 3152 KB Output is correct
48 Correct 19 ms 3888 KB Output is correct
49 Correct 21 ms 3976 KB Output is correct
50 Correct 17 ms 2652 KB Output is correct
51 Correct 19 ms 3888 KB Output is correct
52 Correct 21 ms 4372 KB Output is correct
53 Correct 15 ms 3132 KB Output is correct
54 Correct 19 ms 3896 KB Output is correct
55 Correct 21 ms 4192 KB Output is correct
56 Correct 16 ms 4056 KB Output is correct
57 Correct 15 ms 4056 KB Output is correct
58 Correct 0 ms 348 KB Output is correct