CSES - Datatähti 2016 alku - Results
Submission details
Task:Tontti
Sender:nagrodus
Submission time:2015-10-01 22:48:13 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.06 s1details
#2ACCEPTED0.06 s1details
#30.05 s1details
#40.06 s1details
#50.05 s1details
#60.06 s2details
#70.06 s2details
#8--2details
#9--2details
#10--2details
#110.06 s3details
#12--3details
#13--3details
#14--3details
#15--3details

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:

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:

input
10 10 10
**...*...*
*..*.**.*.
...**.*..*
*...**.*..
...

correct output
4

user output
3

Test 4

Group: 1

Verdict:

input
10 10 5
****......
*.*.**..**
....*.*..*
...*.***..
...

correct output
16

user output
12

Test 5

Group: 1

Verdict:

input
10 10 2
**.***..*.
...*.*....
.***.*...*
***.***..*
...

correct output
30

user output
16

Test 6

Group: 2

Verdict:

input
500 500 1
.................................

correct output
9552040

user output
8

Test 7

Group: 2

Verdict:

input
500 500 5
.................................

correct output
1536063

user output
60

Test 8

Group: 2

Verdict:

input
500 500 25000
**...*...**..*.*..*.**.*..*.*....

correct output
288

user output
(empty)

Test 9

Group: 2

Verdict:

input
500 500 12500
**.**.*..*...*.**...*.***........

correct output
786

user output
(empty)

Test 10

Group: 2

Verdict:

input
500 500 5000
.*.*.**..*.*.**.**..*..**...*....

correct output
1763

user output
(empty)

Test 11

Group: 3

Verdict:

input
2000 2000 1
.................................

correct output
489611392

user output
9

Test 12

Group: 3

Verdict:

input
2000 2000 5
.................................

correct output
120725884

user output
(empty)

Test 13

Group: 3

Verdict:

input
2000 2000 400000
..*..**.**.**.*.***...**.*..**...

correct output
1849

user output
(empty)

Test 14

Group: 3

Verdict:

input
2000 2000 200000
***.*....*.*..*....**..*..*.*....

correct output
2665

user output
(empty)

Test 15

Group: 3

Verdict:

input
2000 2000 80000
**.**...*.***.**....**.*....*....

correct output
5587

user output
(empty)