QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#850901 | #8355. T3 | HuTao# | 0 | 1ms | 4000kb | C++14 | 2.3kb | 2025-01-10 12:52:51 | 2025-01-10 12:52:51 |
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 30;
int n, m;
int u[N], d[N], l[N], r[N];
int a[N][N];
string ans[N];
inline void Check()
{
memset(a, 0, sizeof a);
int i;
for(i = 1; i <= n * n; i ++ )
{
int x = ans[i][1] - '0';
if(ans[i][0] == 'U')
{
int j;
for(j = 1; j <= n; j ++ )
if(!a[j][x])
{
a[j][x] = 1;
break;
}
if(j > n) return ;
}
if(ans[i][0] == 'D')
{
int j;
for(j = n ;j >= 1; j -- )
if(!a[j][x])
{
a[j][x] = 1;
break;
}
if(j < 1) return ;
}
if(ans[i][0] == 'R')
{
int j;
for(j = 1; j <= n; j ++ )
if(!a[x][j])
{
a[x][j] = 1;
break;
}
if(j > n) return ;
}
if(ans[i][0] == 'L')
{
int j;
for(j = n; j >= 1; j -- )
if(!a[x][j])
{
a[x][j] = 1;
break;
}
if(j < 1) break;
}
}
if(i > n * n)
{
for(int i = 1; i <= n * n; i ++ ) printf("%s\n", ans[i].c_str());
exit(0);
}
}
int main()
{
scanf("%d", &n);
int tot = 0;
for(int i = 1; i <= n; i ++ )
{
scanf("%d", &u[i]);
for(int j = 1; j <= u[i]; j ++ )
ans[ ++ tot] = "U" + to_string(i);
}
for(int i = 1; i <= n; i ++ )
{
scanf("%d", &d[i]);
for(int j = 1; j <= d[i]; j ++ )
ans[ ++ tot] = "D" + to_string(i);
}
for(int i = 1; i <= n; i ++ )
{
scanf("%d", &l[i]);
for(int j = 1; j <= l[i]; j ++ )
ans[ ++ tot] = "L" + to_string(i);
}
for(int i = 1; i <= n; i ++ )
{
scanf("%d", &r[i]);
for(int j = 1; j <= r[i]; j ++ )
ans[ ++ tot] = "R" + to_string(i);
}
sort(ans + 1, ans + tot + 1);
do Check();
while(next_permutation(ans + 1, ans + tot + 1));
puts("NO");
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 11
Accepted
time: 1ms
memory: 3796kb
input:
1 0 1 0 0
output:
D1
result:
ok OK
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 4000kb
input:
3 0 0 1 1 1 1 0 1 0 1 2 1
output:
D1 D3 L2 R1 R2 R2 R3 D2 U3
result:
wrong answer A tile is pushed out of the grid.
Subtask #2:
score: 0
Runtime Error
Test #11:
score: 0
Runtime Error
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:
result:
Subtask #3:
score: 0
Runtime Error
Test #21:
score: 0
Runtime Error
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:
result:
Subtask #4:
score: 0
Wrong Answer
Test #31:
score: 25
Accepted
time: 0ms
memory: 3744kb
input:
1 1 0 0 0
output:
U1
result:
ok OK
Test #32:
score: 0
Wrong Answer
time: 0ms
memory: 3752kb
input:
2 0 1 0 1 0 0 1 1
output:
D2 R1 R2 U2
result:
wrong answer A tile is pushed out of the grid.
Subtask #5:
score: 0
Runtime Error
Test #77:
score: 0
Runtime Error
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...