Submission #264789

#TimeUsernameProblemLanguageResultExecution timeMemory
264789GoolakhBuilding 4 (JOI20_building4)C++17
11 / 100
2087 ms23840 KiB
// FUCKED UP FUCKED UP FUCKED UP FUCKED UP FUCKED UP #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math") #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[maxn][2],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; cin>>n; n*=2; for(int b:{0,1})for(int i=1;i<=n;i++) cin>>a[i][b]; mn[1][0]=mx[1][0]=0; mn[1][1]=mx[1][1]=1; for(int i=2;i<=n;i++)for(ll b:{0,1})for(int bb:{0,1})if(a[i][b]>=a[i-1][bb]){ 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,1}){ if(a[i][b]<=gg && mn[i][b]<=bb && bb<=mx[i][b]){ bb-=b; ans=(b ? 'B':'A')+ans; gg=a[i][b]; F=1; break; } } if(!F) return cout<<-1,0; } cout<<ans; return 0; } // a denial a denial a denial a denial a denial a denial

Compilation message (stderr)

building4.cpp:20:58: warning: overflow in conversion from 'double' to 'll' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
   20 | const ll maxn=1e6+10, maxm=1e6+10, lg=10, mod=1e9+7, inf=1e18;
      |                                                          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...