Submission #1055760

# Submission time Handle Problem Language Result Execution time Memory
1055760 2024-08-13T05:04:59 Z d(#11110) Pizza Party (CCO24_day1problem2) C++17
3 / 12
192 ms 25796 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using pii=array<int,2>;
const int N=1000005;
int n,a[N],b[N],cnt[N],ans[2][N];
priority_queue<pii> pq;
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		cnt[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
		cnt[b[i]]--;
		if(cnt[b[i]]<0){
			cout<<"-1\n";
			return 0;
		}
	}
	bool ok=true;
	for(int i=1;i<=n;i++) ok&=b[i]==a[n+1-i];
	if(ok){
		cout<<"1\n";
		for(int i=1;i<=n;i++) cout<<1<<" \n"[i==n];
		for(int i=1;i<=n;i++) cout<<1<<" \n"[i==n];
		return 0;
	}
	cout<<"2\n";
	for(int i=1;i<=n;i++) cout<<a[i]<<" \n"[i==n];
	for(int i=1;i<=n;i++) cout<<b[i]<<" \n"[i==n];
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 123 ms 12116 KB good job!
2 Correct 127 ms 15956 KB good job!
3 Correct 123 ms 16104 KB good job!
4 Correct 130 ms 15956 KB good job!
5 Correct 124 ms 16208 KB good job!
6 Correct 130 ms 15956 KB good job!
7 Correct 134 ms 15956 KB good job!
8 Correct 128 ms 12368 KB good job!
9 Correct 123 ms 12428 KB good job!
10 Correct 124 ms 12208 KB good job!
11 Correct 123 ms 12112 KB good job!
12 Correct 142 ms 12116 KB good job!
13 Correct 0 ms 360 KB good job!
14 Correct 0 ms 348 KB good job!
15 Correct 0 ms 348 KB good job!
16 Correct 55 ms 8076 KB good job!
17 Correct 54 ms 8272 KB good job!
18 Correct 53 ms 8276 KB good job!
19 Correct 53 ms 8276 KB good job!
20 Correct 64 ms 8248 KB good job!
21 Correct 52 ms 8272 KB good job!
22 Correct 137 ms 12112 KB good job!
23 Correct 1 ms 348 KB good job!
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Integer element c_i[1] equals to 3140, violates the range [1, 2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 192 ms 25796 KB Integer element c_i[1] equals to 134990, violates the range [1, 2]
2 Halted 0 ms 0 KB -