Submission #2246099
Source Code Expand
#include<stdio.h>
int path[9][9];
int N, M, rst;
void move(int visited[], int a, int b, int cnt) {
int new_visited[9];
for (int i = 1; i <= N; i++) new_visited[i] = visited[i];
new_visited[b] = 1;
if (cnt == N) {
rst += 1;
return;
}
for (int i = 1; i <= N; i++) {
int f = path[b][i];
if (f == 1 && new_visited[i] != 1) {
move(new_visited, b, i, cnt + 1);
}
}
}
int main() {
int a, b;
int visited[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
rst = 0;
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++)
path[i][j] = 0;
scanf("%d %d", &N, &M);
for (int i = 1; i <= N; i++) {
scanf("%d %d", &a, &b);
path[a][b] = 1;
path[b][a] = 1;
}
path[0][1] = 1;
//for (int i = 1; i <= N; i++) {
// for (int j = 1; j <= N; j++)
// printf("%d", path[i][j]);
// printf("\n");
//}
move(visited, 0, 1, 1);
printf("%d\n", rst);
return 0;
}
Submission Info
Submission Time |
|
Task |
C - One-stroke Path |
User |
mmclsntr |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
979 Byte |
Status |
WA |
Exec Time |
1 ms |
Memory |
128 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:34:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &N, &M);
^
./Main.cpp:37:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &a, &b);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt |
All |
sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
0 ms |
128 KB |
sample_02.txt |
AC |
0 ms |
128 KB |
subtask_1_01.txt |
AC |
0 ms |
128 KB |
subtask_1_02.txt |
AC |
0 ms |
128 KB |
subtask_1_03.txt |
AC |
0 ms |
128 KB |
subtask_1_04.txt |
WA |
0 ms |
128 KB |
subtask_1_05.txt |
AC |
0 ms |
128 KB |
subtask_1_06.txt |
AC |
1 ms |
128 KB |
subtask_1_07.txt |
WA |
0 ms |
128 KB |
subtask_1_08.txt |
WA |
1 ms |
128 KB |
subtask_1_09.txt |
WA |
1 ms |
128 KB |
subtask_1_10.txt |
WA |
0 ms |
128 KB |
subtask_1_11.txt |
WA |
0 ms |
128 KB |
subtask_1_12.txt |
WA |
0 ms |
128 KB |
subtask_1_13.txt |
WA |
0 ms |
128 KB |