Task: | Tontti |
Sender: | Destroy(); |
Submission time: | 2015-10-10 18:20:34 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.05 s | 1 | details |
#2 | ACCEPTED | 0.06 s | 1 | details |
#3 | ACCEPTED | 0.05 s | 1 | details |
#4 | ACCEPTED | 0.05 s | 1 | details |
#5 | ACCEPTED | 0.06 s | 1 | details |
#6 | WRONG ANSWER | 0.15 s | 2 | details |
#7 | WRONG ANSWER | 0.14 s | 2 | details |
#8 | ACCEPTED | 0.20 s | 2 | details |
#9 | ACCEPTED | 0.18 s | 2 | details |
#10 | ACCEPTED | 0.13 s | 2 | details |
#11 | TIME LIMIT EXCEEDED | -- | 3 | details |
#12 | RUNTIME ERROR | 0.43 s | 3 | details |
#13 | RUNTIME ERROR | 0.44 s | 3 | details |
#14 | RUNTIME ERROR | 0.45 s | 3 | details |
#15 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <iostream> #include <string> #include <algorithm> using namespace std; int korkeus, leveys, puut; int summataulukko[2000][2000]; int vakio; void readInput(int x, int y); int lasku(int i, int j, int korkeus, int leveys, int puut); int summataulukkolaske(int x1, int y1, int x2, int y2); int main() { cin >> korkeus >> leveys >> puut; readInput(leveys, korkeus); int lkm = 0; for (int j = 0; j < korkeus; j++) { for (int i = 0; i < leveys; i++) { lkm = lkm + lasku(i, j, korkeus, leveys, puut); } } cout << lkm; } void readInput(int x, int y) { for (int j = 0; j < y; j++) { for (int i = 0; i < x; i++) { char a; cin >> a; vakio = 0; if (a == '*') { vakio = 1; } if (i == 0 && j == 0) { summataulukko[i][j] = vakio; } else if (i == 0) { summataulukko[i][j] = summataulukko[i][j - 1] + vakio; } else if (j == 0) { summataulukko[i][j] = summataulukko[i - 1][j] + vakio; } else { summataulukko[i][j] = summataulukko[i - 1][j] + summataulukko[i][j - 1] + vakio - summataulukko[i - 1][j - 1]; } } } } int lasku(int i, int j, int korkeus, int leveys, int puut) { int maksimi = min(korkeus - j, leveys - i); int pituus = 1; int nykyisetpuut = 0; int lasku = 0; while (nykyisetpuut < puut && pituus <= maksimi) { int lkm2 = summataulukkolaske(i + pituus, j + pituus, i, j); if (lkm2 == puut) lasku += 1; nykyisetpuut = lkm2; pituus++; } return lasku; } int summataulukkolaske(int x1, int y1, int x2, int y2) { int i = x2 - 1; int j = y2 - 1; int vastaus = 0; if (i < 0 && j < 0) { vastaus = summataulukko[x1][y1]; } else if (i < 0) { vastaus = summataulukko[x1][y1] - summataulukko[x1][j]; } else if (j < 0) { vastaus = summataulukko[x1][y1] - summataulukko[i][y1]; } else { vastaus = summataulukko[x1][y1] - summataulukko[i][y1] - summataulukko[x1][j] + summataulukko[i][j]; } return vastaus; }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
input |
---|
10 10 1 ......*... .......*.. *..*....*. *....*.... ... |
correct output |
---|
94 |
user output |
---|
49 |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
10 10 5 ********** ********** ********** ********** ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 3
Group: 1
Verdict: ACCEPTED
input |
---|
10 10 10 **...*...* *..*.**.*. ...**.*..* *...**.*.. ... |
correct output |
---|
4 |
user output |
---|
4 |
Test 4
Group: 1
Verdict: ACCEPTED
input |
---|
10 10 5 ****...... *.*.**..** ....*.*..* ...*.***.. ... |
correct output |
---|
16 |
user output |
---|
16 |
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
10 10 2 **.***..*. ...*.*.... .***.*...* ***.***..* ... |
correct output |
---|
30 |
user output |
---|
30 |
Test 6
Group: 2
Verdict: WRONG ANSWER
input |
---|
500 500 1 ................................. |
correct output |
---|
9552040 |
user output |
---|
129195 |
Test 7
Group: 2
Verdict: WRONG ANSWER
input |
---|
500 500 5 ................................. |
correct output |
---|
1536063 |
user output |
---|
139138 |
Test 8
Group: 2
Verdict: ACCEPTED
input |
---|
500 500 25000 **...*...**..*.*..*.**.*..*.*.... |
correct output |
---|
288 |
user output |
---|
288 |
Test 9
Group: 2
Verdict: ACCEPTED
input |
---|
500 500 12500 **.**.*..*...*.**...*.***........ |
correct output |
---|
786 |
user output |
---|
786 |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
500 500 5000 .*.*.**..*.*.**.**..*..**...*.... |
correct output |
---|
1763 |
user output |
---|
1763 |
Test 11
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
2000 2000 1 ................................. |
correct output |
---|
489611392 |
user output |
---|
(empty) |
Test 12
Group: 3
Verdict: RUNTIME ERROR
input |
---|
2000 2000 5 ................................. |
correct output |
---|
120725884 |
user output |
---|
(empty) |
Test 13
Group: 3
Verdict: RUNTIME ERROR
input |
---|
2000 2000 400000 ..*..**.**.**.*.***...**.*..**... |
correct output |
---|
1849 |
user output |
---|
(empty) |
Test 14
Group: 3
Verdict: RUNTIME ERROR
input |
---|
2000 2000 200000 ***.*....*.*..*....**..*..*.*.... |
correct output |
---|
2665 |
user output |
---|
(empty) |
Test 15
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
2000 2000 80000 **.**...*.***.**....**.*....*.... |
correct output |
---|
5587 |
user output |
---|
(empty) |