Submission #676626

#TimeUsernameProblemLanguageResultExecution timeMemory
676626ensonlungBuilding 4 (JOI20_building4)C++17
0 / 100
2067 ms14272 KiB
#include <bits/stdc++.h> using namespace std; int n,a[200005],b[200005]; string s; void dfs(int id,int as,int bs,string conf){ if (id==2*n){ cout<<conf<<"\n"; exit(0); } int tmp=0; if (conf[id-1]=='A') tmp=a[id]; else tmp=b[id]; if (as<n && a[id+1]>=tmp) dfs(id+1,as+1,bs,conf+'A'); if (bs<n && b[id+1]>=tmp) dfs(id+1,as,bs+1,conf+'B'); } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for (int i=1;i<=2*n;i++) cin>>a[i]; for (int i=1;i<=2*n;i++) cin>>b[i]; dfs(1,1,0,"A"); dfs(1,0,1,"B"); cout<<"-1\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...