제출 #443110

#제출 시각아이디문제언어결과실행 시간메모리
443110cheetose건물 4 (JOI20_building4)C++17
0 / 100
10 ms16380 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define X first #define Y second #define y0 y12 #define y1 y22 #define INF 987654321987654321 #define PI 3.141592653589793238462643383279502884 #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c)) #define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c)) #define MEM0(a) memset((a),0,sizeof(a)) #define MEM_1(a) memset((a),-1,sizeof(a)) #define ALL(a) a.begin(),a.end() #define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin()) #define SYNC ios_base::sync_with_stdio(false);cin.tie(0) using namespace std; typedef long long ll; typedef long double ld; typedef double db; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int, int> Pi; typedef pair<ll, ll> Pll; typedef pair<ld, ld> Pd; typedef vector<int> Vi; typedef vector<ll> Vll; typedef vector<ld> Vd; typedef vector<Pi> VPi; typedef vector<Pll> VPll; typedef vector<Pd> VPd; typedef tuple<int, int, int> iii; typedef tuple<int, int, int, int> iiii; typedef tuple<ll, ll, ll> LLL; typedef vector<iii> Viii; typedef vector<LLL> VLLL; typedef complex<double> base; const int MOD = 1000000021; ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; } int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 }; int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 }; int a[2][1000005]; int d1[2][1000005],d2[2][1000005]; int n; int go1(int k,int N){ if(N==2*n)return 0; int &ret=d1[k][N]; if(~ret)return ret; ret=0; if(a[k][N]<=a[0][N+1])ret=max(ret,1+go1(0,N+1)); if(a[k][N]<=a[1][N+1])ret=max(ret,go1(1,N+1)); return ret; } int go2(int k,int N){ if(N==2*n)return 0; int &ret=d2[k][N]; if(~ret)return ret; ret=0; if(a[k][N]<=a[0][N+1])ret=max(ret,go2(0,N+1)); if(a[k][N]<=a[1][N+1])ret=max(ret,1+go2(1,N+1)); return ret; } vector<char> ans; void track(int k,int N,int remA,int remB){ if(N==2*n)return; if(a[k][N]<=a[0][N+1]){ if(remA-1<=go1(0,N+1) && remB<=go2(0,N+1)){ ans.pb('A'); track(0,N+1,remA-1,remB); return; } } if(a[k][N]<=a[1][N+1]){ if(remA<=go1(1,N+1) && remB-1<=go2(1,N+1)){ ans.pb('B'); track(1,N+1,remA,remB-1); return; } } } int main(){ MEM_1(d1);MEM_1(d2); scanf("%d",&n); fup(i,1,2*n,1)scanf("%d",&a[0][i]); fup(i,1,2*n,1)scanf("%d",&a[1][i]); //if(go1(0,0)<n || go2(0,0)<n)return !printf("-1\n"); track(0,0,n,n); if(ans.size()!=2*n)return !printf("-1\n"); for(char c:ans)printf("%c",c); }

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

building4.cpp: In function 'int main()':
building4.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
building4.cpp:85:2: note: in expansion of macro 'fup'
   85 |  fup(i,1,2*n,1)scanf("%d",&a[0][i]);
      |  ^~~
building4.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
building4.cpp:86:2: note: in expansion of macro 'fup'
   86 |  fup(i,1,2*n,1)scanf("%d",&a[1][i]);
      |  ^~~
building4.cpp:89:15: warning: comparison of integer expressions of different signedness: 'std::vector<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   89 |  if(ans.size()!=2*n)return !printf("-1\n");
      |     ~~~~~~~~~~^~~~~
building4.cpp:84:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
building4.cpp:85:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |  fup(i,1,2*n,1)scanf("%d",&a[0][i]);
      |                ~~~~~^~~~~~~~~~~~~~~
building4.cpp:86:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |  fup(i,1,2*n,1)scanf("%d",&a[1][i]);
      |                ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...