# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
226763 | MKopchev | 건물 4 (JOI20_building4) | C++14 | 2085 ms | 27128 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |