QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#850578#8355. T3kkkgjyismine4#0 31ms4336kbC++201.2kb2025-01-10 10:17:432025-01-10 10:17:44

Judging History

你现在查看的是最新测评结果

  • [2025-01-10 10:17:44]
  • 评测
  • 测评结果:0
  • 用时:31ms
  • 内存:4336kb
  • [2025-01-10 10:17:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
#define N 303
int up[N],dwn[N],lf[N],rg[N],op[N*N],ps[N*N],tt;
void print(){
	for(int i=1;i<=n*n;++i){
		if(op[i]==1)cout<<"U"<<ps[i]<<endl;
		else if(op[i]==2)cout<<"D"<<ps[i]<<endl;
		else if(op[i]==3)cout<<"L"<<ps[i]<<endl;
		else cout<<"R"<<ps[i]<<endl;
	}
}
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
pii val[N];
void Dfs(int x){
	if(!x)return;
	int ct=0;
	for(int i=1;i<=n;++i)val[i].fi=up[i],val[i].se=i,ct+=(up[i]>0);
	sort(val+1,val+n+1),reverse(val+1,val+n+1);
	if(lf[x]+rg[x]+ct<n){
		cout<<"NO\n";
		exit(0);
	}
	ct=n-lf[x]-rg[x];vector<int>vec;
	for(int i=1;i<=ct;++i)vec.pb(val[i].se),--up[val[i].se];
	Dfs(x-1);
	while(lf[x])op[++tt]=3,ps[tt]=x,--lf[x];
	while(rg[x])op[++tt]=4,ps[tt]=x,--rg[x];
	for(int v:vec)op[++tt]=1,ps[tt]=v;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>up[i];
	for(int i=1;i<=n;++i)cin>>dwn[i];
	for(int i=1;i<=n;++i)cin>>lf[i];
	for(int i=1;i<=n;++i){
		cin>>rg[i];
		if(up[i]+dwn[i]>n){
			cout<<"NO\n";
			return 0;
		}
		if(lf[i]+rg[i]>n){
			cout<<"NO\n";
			return 0;
		}
	}
	Dfs(n);
	print();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3512kb

input:

1
0
1
0
0

output:

NO

result:

wrong answer Your program doesn't find a solution

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 27ms
memory: 4296kb

input:

290
28 35 25 29 26 23 36 36 24 39 27 36 24 26 31 28 30 27 25 32 37 26 38 20 31 30 30 35 33 24 25 27 20 26 32 26 33 38 25 29 27 34 25 31 21 22 33 33 24 24 31 31 26 31 25 28 33 27 30 27 24 30 29 26 32 36 20 31 28 23 22 23 37 32 32 27 33 30 27 42 25 31 25 25 26 32 25 35 28 27 33 26 35 39 23 22 26 29 35...

output:

L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
...

result:

wrong answer A tile is pushed out of the grid.

Subtask #3:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 31ms
memory: 4336kb

input:

289
30 29 31 35 25 34 26 28 25 25 44 26 33 30 27 30 33 37 26 27 43 28 28 40 31 36 21 26 35 28 31 29 41 25 30 25 35 28 38 24 26 26 24 24 25 27 18 44 31 24 37 28 26 31 27 32 29 24 24 32 20 35 26 39 30 28 33 30 27 28 37 35 29 22 27 27 31 30 25 31 31 22 30 34 33 31 30 29 41 26 38 36 28 28 21 22 31 34 32...

output:

L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
...

result:

wrong answer A tile is pushed out of the grid.

Subtask #4:

score: 0
Wrong Answer

Test #31:

score: 25
Accepted
time: 0ms
memory: 3828kb

input:

1
1
0
0
0

output:

U1

result:

ok OK

Test #32:

score: 0
Wrong Answer
time: 0ms
memory: 3568kb

input:

2
0 1
0 1
0 0
1 1

output:

NO

result:

wrong answer Your program doesn't find a solution

Subtask #5:

score: 0
Wrong Answer

Test #77:

score: 0
Wrong Answer
time: 2ms
memory: 3992kb

input:

299
72 66 62 73 80 85 70 93 79 88 77 72 67 70 73 84 77 62 80 77 88 63 69 76 73 91 64 76 75 65 74 71 71 68 81 80 74 77 69 75 73 87 90 82 86 79 76 83 69 72 73 73 75 78 76 80 66 76 67 75 72 71 77 63 80 68 82 63 74 67 74 72 73 76 71 72 66 78 74 65 69 80 76 71 72 74 77 70 85 60 65 89 66 64 77 63 78 82 80...

output:

NO

result:

wrong answer Your program doesn't find a solution