# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
264799 | Goolakh | Building 4 (JOI20_building4) | C++17 | 448 ms | 45744 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// FUCKED UP FUCKED UP FUCKED UP FUCKED UP FUCKED UP
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair
typedef int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll maxn=1e6+10, maxm=1e6+10, lg=10, mod=1e9+7, inf=1e18;
ll n,a[2][maxn],mn[maxn][2],mx[maxn][2];
int main(){
//ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
for(int i=0;i<maxn;i++) mn[i][0]=mn[i][1]=mod, mx[i][0]=mx[i][1]=-mod;
scanf("%d",&n); n*=2;
for(int b=0;b<2;b++)for(int i=1;i<=n;i++) scanf("%d",&a[b][i]);
mn[1][0]=mx[1][0]=0;
mn[1][1]=mx[1][1]=1;
for(int i=2;i<=n;i++)for(int b=0;b<2;b++)for(int bb=0;bb<2;bb++)if(a[b][i]>=a[bb][i-1]){
mn[i][b]=min(mn[i][b],mn[i-1][bb]+b);
mx[i][b]=max(mx[i][b],mx[i-1][bb]+b);
}
ll bb=n/2,gg=mod;
string ans="";
for(int i=n;i>=1;i--){
bool F=0;
for(int b=0;b<2;b++){
if(a[b][i]<=gg && mn[i][b]<=bb && bb<=mx[i][b]){
bb-=b;
ans+=(b ? 'B':'A');
gg=a[b][i];
F=1;
break;
}
}
if(!F) return cout<<-1,0;
}
reverse(all(ans));
cout<<ans;
return 0;
}
// a denial a denial a denial a denial a denial a denial
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |