제출 #543260

#제출 시각아이디문제언어결과실행 시간메모리
543260i_am_noob건물 4 (JOI20_building4)C++17
100 / 100
260 ms51908 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,unroll-loops") #define ll long long #define int ll #define ull unsigned ll #define ld long double #define rep(a) rep1(i,a) #define rep1(i,a) rep2(i,0,a) #define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++) #define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--) #define chkmin(a,b) (a=min(a,b)) #define chkmax(a,b) (a=max(a,b)) #define all(a) a.begin(),a.end() #define pii pair<int,int> #define pb push_back //#define inf 1010000000 #define inf 4000000000000000000 #define eps 1e-9 #define sz(a) ((int)a.size()) #define pow2(x) (1ll<<(x)) #define ceiling(a,b) (((a)+(b)-1)/(b)) #define print0(a) cout << (a) << ' ' #define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) #ifdef i_am_noob #define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__) template<typename T> void _do(T && x) {cerr << x << endl;} template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);} #else #define bug(...) 777771449 #endif const int mod=1000000007; const int maxn=1000005,maxm=18,maxk=7777714; //i_am_noob int n,a[maxn],b[maxn],dp[maxn][2][2]; bool res[maxn]; void orzck(){ cin >> n; n*=2; rep(n) cin >> a[i]; rep(n) cin >> b[i]; rep(2) rep1(j,2) dp[0][i][j]=i^1; rep2(i,1,n){ rep1(j,2) dp[i][j][0]=inf,dp[i][j][1]=-inf; if(a[i]>=a[i-1]) chkmin(dp[i][0][0],dp[i-1][0][0]+1),chkmax(dp[i][0][1],dp[i-1][0][1]+1); if(a[i]>=b[i-1]) chkmin(dp[i][0][0],dp[i-1][1][0]+1),chkmax(dp[i][0][1],dp[i-1][1][1]+1); if(b[i]>=a[i-1]) chkmin(dp[i][1][0],dp[i-1][0][0]),chkmax(dp[i][1][1],dp[i-1][0][1]); if(b[i]>=b[i-1]) chkmin(dp[i][1][0],dp[i-1][1][0]),chkmax(dp[i][1][1],dp[i-1][1][1]); } rep(2) rep1(j,2) bug(i,j,dp[n-1][i][j]); int de,tar=n/2,val=inf; rep3(i,n-1,0){ de=-1; rep1(_,2){ if(dp[i][_][0]<=tar&&dp[i][_][1]>=tar&&(_?b[i]:a[i])<=val){ de=_,val=(_?b[i]:a[i]); break; } } bug(de); if(de==-1){ cout << "-1\n"; return; } res[i]=de; tar-=de^1; } rep(n) cout << (res[i]?'B':'A'); cout << "\n"; } signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); orzck(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

building4.cpp: In function 'void orzck()':
building4.cpp:31:18: warning: statement has no effect [-Wunused-value]
   31 | #define bug(...) 777771449
      |                  ^~~~~~~~~
building4.cpp:54:22: note: in expansion of macro 'bug'
   54 |     rep(2) rep1(j,2) bug(i,j,dp[n-1][i][j]);
      |                      ^~~
building4.cpp:31:18: warning: statement has no effect [-Wunused-value]
   31 | #define bug(...) 777771449
      |                  ^~~~~~~~~
building4.cpp:64:9: note: in expansion of macro 'bug'
   64 |         bug(de);
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...