Task: | Gold |
Sender: | AVL-tiimi |
Submission time: | 2017-09-12 17:46:30 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | ACCEPTED | 0.04 s | details |
#3 | ACCEPTED | 0.06 s | details |
#4 | ACCEPTED | 0.04 s | details |
#5 | ACCEPTED | 0.04 s | details |
#6 | ACCEPTED | 0.04 s | details |
#7 | ACCEPTED | 0.04 s | details |
#8 | ACCEPTED | 0.04 s | details |
#9 | ACCEPTED | 0.04 s | details |
#10 | ACCEPTED | 0.04 s | details |
#11 | ACCEPTED | 0.04 s | details |
#12 | ACCEPTED | 0.05 s | details |
#13 | ACCEPTED | 0.04 s | details |
#14 | ACCEPTED | 0.04 s | details |
#15 | ACCEPTED | 0.04 s | details |
#16 | ACCEPTED | 0.05 s | details |
#17 | ACCEPTED | 0.03 s | details |
#18 | ACCEPTED | 0.05 s | details |
#19 | ACCEPTED | 0.04 s | details |
#20 | ACCEPTED | 0.04 s | details |
#21 | ACCEPTED | 0.03 s | details |
#22 | ACCEPTED | 0.05 s | details |
#23 | ACCEPTED | 0.04 s | details |
#24 | ACCEPTED | 0.04 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:38:19: warning: 'py' may be used uninitialized in this function [-Wmaybe-uninitialized] cout << H(px, py) << endl; ^ input/code.cpp:38:19: warning: 'px' may be used uninitialized in this function [-Wmaybe-uninitialized]
Code
#include <iostream> #include <set> using namespace std; int t[50][50], z[50][50]; // 0 . 1 # 2 T 3 G int H(int x, int y) { if (z[x][y] || t[x][y] == 1) return 0; z[x][y] = 1; int r = t[x][y] == 3; int w = (t[x-1][y] == 2 || t[x+1][y] == 2 || t[x][y-1] == 2 || t[x][y+1] == 2); if (!w) { r += H(x+1, y); r += H(x-1, y); r += H(x, y+1); r += H(x, y-1); } return r; } int main() { ios::sync_with_stdio(0); cin.tie(0); int w, h; cin >> w >> h; int px, py; for (int i = 0; i < h; ++i) { cin >> ws; for (int j = 0; j < w; ++j) { char c; cin >> c; if (c == '#') t[i][j] = 1; if (c == 'T') t[i][j] = 2; if (c == 'G') t[i][j] = 3; if (c == 'P') { px = i, py = j; } } } cout << H(px, py) << endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
8 6 ######## #...GTG# #..PG.G# #...G#G# ... |
correct output |
---|
4 |
user output |
---|
4 |
Test 2
Verdict: ACCEPTED
input |
---|
7 4 ####### #P.GTG# #..TGG# ####### |
correct output |
---|
1 |
user output |
---|
1 |
Test 3
Verdict: ACCEPTED
input |
---|
50 50 ##############################... |
correct output |
---|
2303 |
user output |
---|
2303 |
Test 4
Verdict: ACCEPTED
input |
---|
50 50 ##############################... |
correct output |
---|
1 |
user output |
---|
1 |
Test 5
Verdict: ACCEPTED
input |
---|
50 50 ##############################... |
correct output |
---|
0 |
user output |
---|
0 |
Test 6
Verdict: ACCEPTED
input |
---|
50 50 ##############################... |
correct output |
---|
2 |
user output |
---|
2 |
Test 7
Verdict: ACCEPTED
input |
---|
50 50 ##############################... |
correct output |
---|
1196 |
user output |
---|
1196 |
Test 8
Verdict: ACCEPTED
input |
---|
50 50 ##############################... |
correct output |
---|
1 |
user output |
---|
1 |
Test 9
Verdict: ACCEPTED
input |
---|
50 50 ##############################... |
correct output |
---|
0 |
user output |
---|
0 |
Test 10
Verdict: ACCEPTED
input |
---|
50 50 ##############################... |
correct output |
---|
130 |
user output |
---|
130 |
Test 11
Verdict: ACCEPTED
input |
---|
50 50 ##############################... |
correct output |
---|
0 |
user output |
---|
0 |
Test 12
Verdict: ACCEPTED
input |
---|
3 3 ### #P# ### |
correct output |
---|
0 |
user output |
---|
0 |
Test 13
Verdict: ACCEPTED
input |
---|
3 50 ### #G# #T# #G# ... |
correct output |
---|
45 |
user output |
---|
45 |
Test 14
Verdict: ACCEPTED
input |
---|
50 3 ##############################... |
correct output |
---|
45 |
user output |
---|
45 |
Test 15
Verdict: ACCEPTED
input |
---|
5 4 ##### #TGG# #G#P# ##### |
correct output |
---|
2 |
user output |
---|
2 |
Test 16
Verdict: ACCEPTED
input |
---|
37 20 ##############################... |
correct output |
---|
0 |
user output |
---|
0 |
Test 17
Verdict: ACCEPTED
input |
---|
16 37 ################ #.G.G.G#GG.G.#G# ##....G...#G..## #G...#.#GG.....# ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 18
Verdict: ACCEPTED
input |
---|
17 42 ################# ##G...#.....##..# #G..........G.### #.G..##G.G.G...G# ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 19
Verdict: ACCEPTED
input |
---|
42 24 ##############################... |
correct output |
---|
133 |
user output |
---|
133 |
Test 20
Verdict: ACCEPTED
input |
---|
32 35 ##############################... |
correct output |
---|
736 |
user output |
---|
736 |
Test 21
Verdict: ACCEPTED
input |
---|
21 43 ##################### #G.##G#GGGGG#G#GG##G# #GG##GGT#GG###GG#GGG# #GGGTGG..G#G...TG##G# ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 22
Verdict: ACCEPTED
input |
---|
47 14 ##############################... |
correct output |
---|
252 |
user output |
---|
252 |
Test 23
Verdict: ACCEPTED
input |
---|
18 21 ################## ##G.T#.GGG.G....## #G..T....GG.G#..G# #.#..#..#..TG#G.G# ... |
correct output |
---|
97 |
user output |
---|
97 |
Test 24
Verdict: ACCEPTED
input |
---|
32 16 ##############################... |
correct output |
---|
69 |
user output |
---|
69 |