Submission #33904
Source Code Expand
Copy
#include <cstdio> #include <set> #include <stack> using namespace std; int h, w, c = 1; char s[1000][1001]; int a[1000][1000]; int f[1000][1000]; int dx[4] = {0, 0, 1, -1}; int dy[4] = {1, -1, 0, 0}; int dx2[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dy2[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; set <int> se; bool in(int x, int y) { if (x >= 0 && x < h && y >= 0 && y < w) { return true; } else { return false; } } void dfs(int x, int y) { int i; stack <pair<int, int> > st; st.push(make_pair(x, y)); while (!st.empty()) { x = st.top().first; y = st.top().second; st.pop(); a[x][y] = c; for (i = 0; i < 4; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (in(nx, ny) && s[nx][ny] == '.' && a[nx][ny] == 0) st.push(make_pair(nx, ny)); } } } void dfs2(int x, int y) { int i; stack <pair<int, int> > st; st.push(make_pair(x, y)); while (!st.empty()) { int x = st.top().first; int y = st.top().second; st.pop(); f[x][y] = 1; for (i = 0; i < 8; i++) { int nx = x + dx2[i]; int ny = y + dy2[i]; if (in(nx, ny)) { if (s[nx][ny] == '.') { se.insert(a[nx][ny]); } else if (f[nx][ny] == 0) { st.push(make_pair(nx, ny)); } } } } } int main() { int i, j; int b[3] = {0}; scanf("%d %d", &h, &w); for (i = 0; i < h; i++) scanf("%s", s[i]); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (s[i][j] == '.' && a[i][j] == 0) { dfs(i, j); c++; } } } c = 1; for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (s[i][j] == 'o' && f[i][j] == 0) { se.clear(); dfs2(i, j); if (se.size() == 2) { b[0]++; } else if (se.size() == 3) { b[1]++; } else { b[2]++; } } } } printf("%d %d %d\n", b[0], b[1], b[2]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - アルファベット探し |
User | kawatea |
Language | C++ (G++ 4.6.4) |
Score | 100 |
Code Size | 2555 Byte |
Status | AC |
Exec Time | 195 ms |
Memory | 13836 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:85:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] ./Main.cpp:87:46: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_min.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rndsmall_00.txt, 01_rndsmall_01.txt, 01_rndsmall_02.txt, 01_rndsmall_03.txt, 01_rndsmall_04.txt, 01_rndsmall_05.txt, 01_rndsmall_06.txt, 01_rndsmall_07.txt, 01_rndsmall_08.txt, 01_rndsmall_09.txt, 01_rndsmall_10.txt, 01_rndsmall_11.txt, 01_rndsmall_12.txt, 01_rndsmall_13.txt, 01_rndsmall_14.txt, 01_rndsmall_15.txt, 01_rndsmall_16.txt, 01_rndsmall_17.txt, 01_rndsmall_18.txt, 01_rndsmall_19.txt, 02_rndmax_00.txt, 02_rndmax_01.txt, 02_rndmax_02.txt, 02_rndmax_03.txt, 02_rndmax_04.txt, 02_rndmax_05.txt, 02_rndmax_06.txt, 02_rndmax_07.txt, 02_rndmax_08.txt, 02_rndmax_09.txt, 02_rndmax_10.txt, 02_rndmax_11.txt, 02_rndmax_12.txt, 02_rndmax_13.txt, 02_rndmax_14.txt, 02_rndmax_15.txt, 02_rndmax_16.txt, 02_rndmax_17.txt, 02_rndmax_18.txt, 02_rndmax_19.txt, 03_rnd_00.txt, 03_rnd_01.txt, 03_rnd_02.txt, 03_rnd_03.txt, 03_rnd_04.txt, 03_rnd_05.txt, 03_rnd_06.txt, 03_rnd_07.txt, 03_rnd_08.txt, 03_rnd_09.txt, 04_empty_00.txt, 05_maxret_00.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_min.txt | AC | 21 ms | 796 KB |
00_sample_01.txt | AC | 21 ms | 788 KB |
00_sample_02.txt | AC | 21 ms | 792 KB |
00_sample_03.txt | AC | 20 ms | 912 KB |
00_sample_04.txt | AC | 21 ms | 796 KB |
00_sample_05.txt | AC | 22 ms | 1016 KB |
01_rndsmall_00.txt | AC | 24 ms | 1668 KB |
01_rndsmall_01.txt | AC | 23 ms | 1536 KB |
01_rndsmall_02.txt | AC | 24 ms | 1648 KB |
01_rndsmall_03.txt | AC | 25 ms | 1660 KB |
01_rndsmall_04.txt | AC | 24 ms | 1664 KB |
01_rndsmall_05.txt | AC | 24 ms | 1652 KB |
01_rndsmall_06.txt | AC | 24 ms | 1668 KB |
01_rndsmall_07.txt | AC | 24 ms | 1656 KB |
01_rndsmall_08.txt | AC | 24 ms | 1560 KB |
01_rndsmall_09.txt | AC | 25 ms | 1660 KB |
01_rndsmall_10.txt | AC | 24 ms | 1536 KB |
01_rndsmall_11.txt | AC | 24 ms | 1556 KB |
01_rndsmall_12.txt | AC | 24 ms | 1660 KB |
01_rndsmall_13.txt | AC | 24 ms | 1672 KB |
01_rndsmall_14.txt | AC | 24 ms | 1656 KB |
01_rndsmall_15.txt | AC | 25 ms | 1672 KB |
01_rndsmall_16.txt | AC | 24 ms | 1528 KB |
01_rndsmall_17.txt | AC | 24 ms | 1676 KB |
01_rndsmall_18.txt | AC | 23 ms | 1584 KB |
01_rndsmall_19.txt | AC | 24 ms | 1676 KB |
02_rndmax_00.txt | AC | 137 ms | 9840 KB |
02_rndmax_01.txt | AC | 143 ms | 9612 KB |
02_rndmax_02.txt | AC | 173 ms | 9632 KB |
02_rndmax_03.txt | AC | 151 ms | 9700 KB |
02_rndmax_04.txt | AC | 163 ms | 9644 KB |
02_rndmax_05.txt | AC | 139 ms | 9616 KB |
02_rndmax_06.txt | AC | 155 ms | 12876 KB |
02_rndmax_07.txt | AC | 142 ms | 10848 KB |
02_rndmax_08.txt | AC | 147 ms | 9480 KB |
02_rndmax_09.txt | AC | 139 ms | 9756 KB |
02_rndmax_10.txt | AC | 135 ms | 9436 KB |
02_rndmax_11.txt | AC | 137 ms | 9696 KB |
02_rndmax_12.txt | AC | 141 ms | 9744 KB |
02_rndmax_13.txt | AC | 151 ms | 11224 KB |
02_rndmax_14.txt | AC | 168 ms | 13772 KB |
02_rndmax_15.txt | AC | 164 ms | 9640 KB |
02_rndmax_16.txt | AC | 140 ms | 9596 KB |
02_rndmax_17.txt | AC | 131 ms | 9456 KB |
02_rndmax_18.txt | AC | 129 ms | 9480 KB |
02_rndmax_19.txt | AC | 144 ms | 9812 KB |
03_rnd_00.txt | AC | 26 ms | 1148 KB |
03_rnd_01.txt | AC | 54 ms | 6808 KB |
03_rnd_02.txt | AC | 51 ms | 3028 KB |
03_rnd_03.txt | AC | 51 ms | 5112 KB |
03_rnd_04.txt | AC | 54 ms | 3528 KB |
03_rnd_05.txt | AC | 27 ms | 1696 KB |
03_rnd_06.txt | AC | 79 ms | 6120 KB |
03_rnd_07.txt | AC | 37 ms | 2728 KB |
03_rnd_08.txt | AC | 89 ms | 8668 KB |
03_rnd_09.txt | AC | 77 ms | 5856 KB |
04_empty_00.txt | AC | 113 ms | 13836 KB |
05_maxret_00.txt | AC | 195 ms | 9048 KB |