Submission #899620

#TimeUsernameProblemLanguageResultExecution timeMemory
899620LCJLY건물 4 (JOI20_building4)C++14
0 / 100
1 ms416 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl; 
#define show4(x,y) for(auto it:x) cout << it << " "; cout << #y << endl;
typedef pair<long long,long long>pii;
typedef pair<pii,pii>pi2;

void solve(){	
	int n;
	cin >> n;
	int arr[2*n];
	int arr2[2*n];
	
	for(int x=0;x<2*n;x++){
		cin >> arr[x];
	}
	
	for(int x=0;x<2*n;x++){
		cin >> arr2[x];
	}
	
	vector<char>ans;
	
	int cur=0;
	for(int x=0;x<2*n;x++){
		if(arr[x]>=cur&&arr2[x]>=cur){
			if(arr[x]<=arr2[x]){
				cur=arr[x];
				ans.push_back('A');
			}
			else{
				cur=arr2[x];
				ans.push_back('B');
			}
		}
		else if(arr[x]>=cur){
			cur=arr[x];
			ans.push_back('A');
		}
		else if(arr2[x]>=cur){
			cur=arr2[x];
			ans.push_back('B');
		}
		else{
			cout << -1;
			return;
		}
	}
	
	for(auto it:ans)cout << it;
}	

int32_t main(){										
	ios::sync_with_stdio(0);	
	cin.tie(0);
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}
}

/*
4 5 
0 1 
0 2 
1 2 
1 3 
2 3 
*/
		
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...