제출 #264799

#제출 시각아이디문제언어결과실행 시간메모리
264799Goolakh건물 4 (JOI20_building4)C++17
100 / 100
448 ms45744 KiB
// 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

컴파일 시 표준 에러 (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;
      |                                                          ^~~~
building4.cpp: In function 'int main()':
building4.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |  scanf("%d",&n); n*=2;
      |  ~~~~~^~~~~~~~~
building4.cpp:29:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |  for(int b=0;b<2;b++)for(int i=1;i<=n;i++) scanf("%d",&a[b][i]);
      |                                            ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...