| Task: | Tontti |
| Sender: | nagrodus |
| Submission time: | 2015-10-01 22:48:13 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.06 s | 1 | details |
| #2 | ACCEPTED | 0.06 s | 1 | details |
| #3 | WRONG ANSWER | 0.05 s | 1 | details |
| #4 | WRONG ANSWER | 0.06 s | 1 | details |
| #5 | WRONG ANSWER | 0.05 s | 1 | details |
| #6 | WRONG ANSWER | 0.06 s | 2 | details |
| #7 | WRONG ANSWER | 0.06 s | 2 | details |
| #8 | TIME LIMIT EXCEEDED | -- | 2 | details |
| #9 | TIME LIMIT EXCEEDED | -- | 2 | details |
| #10 | TIME LIMIT EXCEEDED | -- | 2 | details |
| #11 | WRONG ANSWER | 0.06 s | 3 | details |
| #12 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #13 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #14 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #15 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
ios_base::sync_with_stdio(0);
int yMax, xMax, target;
cin >> yMax >> xMax >> target;
bool *arr = new bool[yMax*xMax];
char *line = new char[xMax + 1];
for (int i = 0; i < yMax; i++){
cin >> line;
for (int j = 0; j < xMax; j++){
if (line[j] == '*')
arr[(i*xMax) + j] = true;
else
arr[(i*xMax) + j] = false;
}
}
delete[] line;
int areas = 0;
for (int y = 0; y < yMax; y++){
for (int x = 0; x < xMax; x++){
if (arr[(y*xMax) + x]){
int range=1,trees=0;
int yDown = (range+1)/2;
int yUp = range - yDown;
while ((x + range) < xMax && (y + yDown) < yMax && (y - yUp) >= 0 && trees<target){
trees = 0;
int xTemp, yTemp;
for (yTemp = y - yUp; yTemp < y + yDown +1; yTemp++){
for (xTemp = x; xTemp < x + range +1; xTemp++){
if (arr[(yTemp*xMax) + xTemp]){
trees++;
}
}
}
if (trees == target){
//cout << "x:" << x << "\ny:" << y << "\nrange: " << range <<"\nTrees off: "<< x << endl;
areas++;
}
range++;
yDown = (range + 1) / 2;
yUp = range - yDown;
}
range = 2;
yDown = range;
while ((x + range) < xMax && (y + yDown) < yMax && trees<target){
trees = 0;
int xTemp, yTemp;
for (yTemp = y; yTemp < y + yDown + 1; yTemp++){
for (xTemp = x; xTemp < x + range + 1; xTemp++){
if (arr[(yTemp*xMax) + xTemp]){
trees++;
}
}
}
if (trees == target){
//cout << "x:" << x << "\ny:" << y << "\nrange: " << range << "\nTrees off: " << x << endl;
areas++;
}
range++;
yDown = (range + 1) / 2;
}
}
}
}
/*for (int i = 0; i < yMax*xMax; i++){
if (arr[i])
cout << "1";
else
cout << "0";
}*/
cout << areas;
delete[] arr;
//system("pause");
return 0;
}
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 1 ......*... .......*.. *..*....*. *....*.... ... |
| correct output |
|---|
| 94 |
| user output |
|---|
| 6 |
Test 2
Group: 1
Verdict: ACCEPTED
| input |
|---|
| 10 10 5 ********** ********** ********** ********** ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 3
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 10 **...*...* *..*.**.*. ...**.*..* *...**.*.. ... |
| correct output |
|---|
| 4 |
| user output |
|---|
| 3 |
Test 4
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 5 ****...... *.*.**..** ....*.*..* ...*.***.. ... |
| correct output |
|---|
| 16 |
| user output |
|---|
| 12 |
Test 5
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 2 **.***..*. ...*.*.... .***.*...* ***.***..* ... |
| correct output |
|---|
| 30 |
| user output |
|---|
| 16 |
Test 6
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 1 ................................. |
| correct output |
|---|
| 9552040 |
| user output |
|---|
| 8 |
Test 7
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 500 500 5 ................................. |
| correct output |
|---|
| 1536063 |
| user output |
|---|
| 60 |
Test 8
Group: 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500 500 25000 **...*...**..*.*..*.**.*..*.*.... |
| correct output |
|---|
| 288 |
| user output |
|---|
| (empty) |
Test 9
Group: 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500 500 12500 **.**.*..*...*.**...*.***........ |
| correct output |
|---|
| 786 |
| user output |
|---|
| (empty) |
Test 10
Group: 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500 500 5000 .*.*.**..*.*.**.**..*..**...*.... |
| correct output |
|---|
| 1763 |
| user output |
|---|
| (empty) |
Test 11
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 2000 2000 1 ................................. |
| correct output |
|---|
| 489611392 |
| user output |
|---|
| 9 |
Test 12
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 2000 2000 5 ................................. |
| correct output |
|---|
| 120725884 |
| user output |
|---|
| (empty) |
Test 13
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 2000 2000 400000 ..*..**.**.**.*.***...**.*..**... |
| correct output |
|---|
| 1849 |
| user output |
|---|
| (empty) |
Test 14
Group: 3
Verdict: TIME LIMIT EXCEEDED
| 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) |
