Submission #1141451
Source Code Expand
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
char dc[4] = { 'R','D','L','U' };
bool flag[50][50];
int dat[50][50];
typedef pair<int, int>pii;
vector<char>ans;
void dfs(int x, int y)
{
if (ans.size() >= 2500)return;
flag[x][y] = true;
for (int i = 0; i < 4; i++)
{
if (dat[x + dx[i]][y + dy[i]] == 0 && (!flag[x + dx[i]][y + dy[i]]))
{
ans.push_back(dc[i]);
dfs(x + dx[i], y + dy[i]);
ans.push_back(dc[(i + 2) % 4]);
}
}
}
int main()
{
int mx, my, kai, sx, sy;
scanf("%d%d%d%d%d", &mx, &my, &kai, &sx, &sy);
sx--, sy--;
for (int i = 0; i < mx; i++)
{
for (int j = 0; j < my; j++)
{
char z;
scanf(" %c", &z);
if (z == '#')dat[i][j] = 1;
}
}
dfs(sx, sy);
for (int i = ans.size(); i < 2500; i++)ans.push_back('-');
for (int i = 0; i < 2500; i++)printf("%c", ans[i]); printf("\n");
}
Submission Info
Submission Time |
|
Task |
B - Food Collector |
User |
DEGwer |
Language |
C++14 (GCC 5.4.1) |
Score |
7182 |
Code Size |
947 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:29:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d%d", &mx, &my, &kai, &sx, &sy);
^
./Main.cpp:36:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(" %c", &z);
^
Judge Result
Set Name |
test_01 |
test_02 |
test_03 |
test_04 |
test_05 |
test_06 |
test_07 |
test_08 |
test_09 |
test_10 |
Score / Max Score |
907 / 20000 |
941 / 20000 |
352 / 20000 |
341 / 20000 |
981 / 20000 |
1124 / 20000 |
790 / 20000 |
621 / 20000 |
613 / 20000 |
512 / 20000 |
Status |
|
|
|
|
|
|
|
|
|
|
Set Name |
Test Cases |
test_01 |
subtask_01_01.txt |
test_02 |
subtask_01_02.txt |
test_03 |
subtask_01_03.txt |
test_04 |
subtask_01_04.txt |
test_05 |
subtask_01_05.txt |
test_06 |
subtask_01_06.txt |
test_07 |
subtask_01_07.txt |
test_08 |
subtask_01_08.txt |
test_09 |
subtask_01_09.txt |
test_10 |
subtask_01_10.txt |
Case Name |
Status |
Exec Time |
Memory |
subtask_01_01.txt |
AC |
1 ms |
256 KB |
subtask_01_02.txt |
AC |
1 ms |
256 KB |
subtask_01_03.txt |
AC |
1 ms |
256 KB |
subtask_01_04.txt |
AC |
1 ms |
256 KB |
subtask_01_05.txt |
AC |
1 ms |
256 KB |
subtask_01_06.txt |
AC |
1 ms |
256 KB |
subtask_01_07.txt |
AC |
1 ms |
256 KB |
subtask_01_08.txt |
AC |
1 ms |
256 KB |
subtask_01_09.txt |
AC |
1 ms |
256 KB |
subtask_01_10.txt |
AC |
1 ms |
256 KB |