Submission #75093420
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
char dc[] = {'U', 'L', 'R', 'D'};
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
int n, a, b;
cin >> n >> a >> b;
if ((a + b) % 2 == 0)
{ // 正确判断,替换你错误的 n%2==1
cout << "No\n";
continue;
}
cout << "Yes\n";
vector<vector<int>> vis(n + 1, vector<int>(n + 1, 0));
int x = 1, y = 1;
vis[x][y] = 1;
string path;
path.reserve(n * n);
for (int step = 0; step < n * n - 2; step++)
{
int maxdist = -1;
int best = -1, nx, ny;
for (int i = 0; i < 4; i++)
{
int xx = x + dx[i];
int yy = y + dy[i];
if (xx < 1 || xx > n || yy < 1 || yy > n)
continue;
if (xx == a && yy == b)
continue;
if (vis[xx][yy])
continue;
int d = (n - xx) * (n - xx) + (n - yy) * (n - yy);
if (d > maxdist)
{
maxdist = d;
best = i;
nx = xx;
ny = yy;
}
}
path += dc[best];
vis[nx][ny] = 1;
x = nx;
y = ny;
if (x == n && y == n)
break;
}
cout << path << '\n';
}
return 0;
}
Submission Info
Submission Time
2026-04-18 23:33:31+0900
Task
E - LRUD Moving
User
RageLog
Language
C++23 (GCC 15.2.0)
Score
0
Code Size
1662 Byte
Status
WA
Exec Time
14 ms
Memory
8388 KiB
Compile Error
./Main.cpp: In function 'main':
./Main.cpp:64:13: warning: 'nx' may be used uninitialized [-Wmaybe-uninitialized]
64 | if (x == n && y == n)
| ^
./Main.cpp:36:28: note: 'nx' was declared here
36 | int best = -1, nx, ny;
| ^
./Main.cpp:60:23: warning: 'ny' may be used uninitialized [-Wmaybe-uninitialized]
60 | vis[nx][ny] = 1;
| ^
./Main.cpp:36:32: note: 'ny' was declared here
36 | int best = -1, nx, ny;
| ^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
0 / 450
Status
Set Name
Test Cases
Sample
00_sample_00.txt
All
00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 01_handmade_14.txt, 01_handmade_15.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt
Case Name
Status
Exec Time
Memory
00_sample_00.txt
AC
1 ms
3460 KiB
01_handmade_00.txt
AC
14 ms
8264 KiB
01_handmade_01.txt
AC
13 ms
8316 KiB
01_handmade_02.txt
AC
13 ms
8332 KiB
01_handmade_03.txt
WA
11 ms
8264 KiB
01_handmade_04.txt
WA
13 ms
8160 KiB
01_handmade_05.txt
AC
13 ms
8300 KiB
01_handmade_06.txt
AC
13 ms
8160 KiB
01_handmade_07.txt
WA
12 ms
8332 KiB
01_handmade_08.txt
WA
12 ms
8152 KiB
01_handmade_09.txt
AC
1 ms
3540 KiB
01_handmade_10.txt
WA
7 ms
3588 KiB
01_handmade_11.txt
WA
5 ms
3440 KiB
01_handmade_12.txt
WA
6 ms
3876 KiB
01_handmade_13.txt
WA
6 ms
3788 KiB
01_handmade_14.txt
WA
6 ms
3788 KiB
01_handmade_15.txt
WA
6 ms
3596 KiB
02_random_00.txt
WA
13 ms
8332 KiB
02_random_01.txt
WA
13 ms
8388 KiB
02_random_02.txt
WA
12 ms
8316 KiB
02_random_03.txt
WA
12 ms
8304 KiB
02_random_04.txt
WA
13 ms
8324 KiB
02_random_05.txt
WA
12 ms
3596 KiB
02_random_06.txt
WA
11 ms
3908 KiB
02_random_07.txt
AC
1 ms
3464 KiB
02_random_08.txt
AC
1 ms
3464 KiB
02_random_09.txt
AC
1 ms
3632 KiB
02_random_10.txt
AC
1 ms
3632 KiB
02_random_11.txt
AC
1 ms
3644 KiB
02_random_12.txt
AC
1 ms
3540 KiB