제출 #226763

#제출 시각아이디문제언어결과실행 시간메모리
226763MKopchev건물 4 (JOI20_building4)C++14
11 / 100
2085 ms27128 KiB
#include<bits/stdc++.h> using namespace std; const int nmax=2e3+42; bool been[2*nmax][2][nmax]; int n; int a[2*nmax],b[2*nmax]; string current; void go(int pos,bool side,int a_taken) { if(side==0)current.push_back('A'); else current.push_back('B'); if(been[pos][side][a_taken]) { current.pop_back(); return; } been[pos][side][a_taken]=1; //cout<<"go "<<a_taken<<" "<<b_taken<<" "<<side<<endl; if(a_taken==n&&pos==2*n+1) { for(int i=1;i<=2*n;i++)printf("%c",current[i]); printf("\n"); exit(0); } int lst=(side==0?a[pos-1]:b[pos-1]); int b_taken=pos-1-a_taken; //use a if(a_taken<n&&lst<=a[pos])go(pos+1,0,a_taken+1); //use b if(b_taken<n&&lst<=b[pos])go(pos+1,1,a_taken); current.pop_back(); } int main() { scanf("%i",&n); for(int i=1;i<=2*n;i++)scanf("%i",&a[i]); for(int i=1;i<=2*n;i++)scanf("%i",&b[i]); go(1,0,0); printf("-1\n"); return 0; }

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

building4.cpp: In function 'int main()':
building4.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
building4.cpp:48:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=2*n;i++)scanf("%i",&a[i]);
                            ~~~~~^~~~~~~~~~~~
building4.cpp:49:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=2*n;i++)scanf("%i",&b[i]);
                            ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...