Submission #3731780
Source Code Expand
#include "bits/stdc++.h" using namespace std; //#include <stdio.h> //#include <assert.h> #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define DIVUP(x, y) (((x) + ((y) - 1)) / (y)) #define DIVOFF(x, y) (((x) + ((y) / 2)) / (y)) #define REMAINDER(x, y) ((x) % (y)) #define H_MAX 10 #define W_MAX 10 char grid[H_MAX][W_MAX + 1]; bool reached[H_MAX][W_MAX]; int land_num; int count; bool dfs(int h, int w) { if (h < 0 || h >= H_MAX || w < 0 || w >= W_MAX || reached[h][w] || (::count == 0 && grid[h][w] == 'o') || (::count > 0 && grid[h][w] == 'x')) return false; reached[h][w] = true; ++::count; if (::count > land_num) return true; if (dfs(h - 1, w)) return true; if (dfs(h + 1, w)) return true; if (dfs(h, w - 1)) return true; if (dfs(h, w + 1)) return true; return false; } int main() { for (int h{0}; h < H_MAX; ++h) { scanf("%10s", &grid[h][0]); for (int w{0}; w < W_MAX; ++w) { if (grid[h][w] == 'o') ++land_num; } } bool ans; for (int h{0}; h < H_MAX; ++h) { for (int w{0}; w < W_MAX; ++w) { memset(reached, 0, sizeof reached); ::count = 0; ans = dfs(h, w); if (ans) goto END; } } END: printf("%s\n", ans ? "YES" : "NO"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - 埋め立て |
User | tatsu |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 1337 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:38:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%10s", &grid[h][0]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 10_rand_00.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 10_rand_09.txt, 10_rand_10.txt, 10_rand_11.txt, 10_rand_12.txt, 10_rand_13.txt, 10_rand_14.txt, 10_rand_15.txt, 10_rand_16.txt, 10_rand_17.txt, 10_rand_18.txt, 10_rand_19.txt, 10_rand_20.txt, 10_rand_21.txt, 10_rand_22.txt, 10_rand_23.txt, 10_rand_24.txt, 10_rand_25.txt, 10_rand_26.txt, 10_rand_27.txt, 10_rand_28.txt, 10_rand_29.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 256 KB |
00_sample_01.txt | AC | 1 ms | 256 KB |
00_sample_02.txt | AC | 1 ms | 256 KB |
10_rand_00.txt | AC | 1 ms | 256 KB |
10_rand_01.txt | AC | 1 ms | 256 KB |
10_rand_02.txt | AC | 1 ms | 256 KB |
10_rand_03.txt | AC | 1 ms | 256 KB |
10_rand_04.txt | AC | 1 ms | 256 KB |
10_rand_05.txt | AC | 1 ms | 256 KB |
10_rand_06.txt | AC | 1 ms | 256 KB |
10_rand_07.txt | AC | 1 ms | 256 KB |
10_rand_08.txt | AC | 1 ms | 256 KB |
10_rand_09.txt | AC | 1 ms | 256 KB |
10_rand_10.txt | AC | 1 ms | 256 KB |
10_rand_11.txt | AC | 1 ms | 256 KB |
10_rand_12.txt | AC | 1 ms | 256 KB |
10_rand_13.txt | AC | 1 ms | 256 KB |
10_rand_14.txt | AC | 1 ms | 256 KB |
10_rand_15.txt | AC | 1 ms | 256 KB |
10_rand_16.txt | AC | 1 ms | 256 KB |
10_rand_17.txt | AC | 1 ms | 256 KB |
10_rand_18.txt | AC | 1 ms | 256 KB |
10_rand_19.txt | AC | 1 ms | 256 KB |
10_rand_20.txt | AC | 1 ms | 256 KB |
10_rand_21.txt | AC | 1 ms | 256 KB |
10_rand_22.txt | AC | 1 ms | 256 KB |
10_rand_23.txt | AC | 1 ms | 256 KB |
10_rand_24.txt | AC | 1 ms | 256 KB |
10_rand_25.txt | AC | 1 ms | 256 KB |
10_rand_26.txt | AC | 1 ms | 256 KB |
10_rand_27.txt | AC | 1 ms | 256 KB |
10_rand_28.txt | AC | 1 ms | 256 KB |
10_rand_29.txt | AC | 1 ms | 256 KB |