CSES - KILO 2018 4/5 - Results
Submission details
Task:Habitat
Sender:Pohjantahti
Submission time:2018-09-27 17:32:21 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1UNKNOWN--details
#2UNKNOWN--details
#3UNKNOWN--details
#4UNKNOWN--details
#5UNKNOWN--details
#6UNKNOWN--details
#7UNKNOWN--details
#8UNKNOWN--details
#9UNKNOWN--details
#10UNKNOWN--details
#11UNKNOWN--details
#12UNKNOWN--details
#13UNKNOWN--details
#14UNKNOWN--details
#15UNKNOWN--details

Code

#include <iostream>

using namespace std;
typedef long long ll;

const int N = 100;

int n;
int t[N+5][N+5];

ll res[N*N+5];

void lisaa_range(int a, int b, ll x) {
	res[a] += x;
	res[b+1] -= x;
}

int dist(int y1, int x1, int y2, int x2) {
	return abs(y2-y1) + abs(x2-x1);
}

bool ok(int y, int x, int k) {
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if ((dist(y, x, i, j) <= k) && (t[i][j] <= k)) {
				return true;
			}
		}
	}
	return false;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			cin >> t[i][j];
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			int k = -1;
			for (int jp = (1<<14); jp >= 1; jp /= 2) {
				if (k+jp < t[i][j] && !ok(i, j, k+jp)) k += jp;
			}
			k++;
			if (k < t[i][j]) {
				lisaa_range(k, t[i][j]-1, 1);
			}
		}
	}
	ll cres = 0;
	for (int i = 0; i <= n*n; ++i) {
		cres += res[i];
		cout << cres << " ";
	}
	cout << "\n";
	return 0;
}

Test details

Test 1

Verdict: UNKNOWN

input
2
1 4
2 3

correct output
0 2 2 1 0 

user output
(not available)

Test 2

Verdict: UNKNOWN

input
1
1

correct output
0 0 

user output
(not available)

Test 3

Verdict: UNKNOWN

input
100
56 7 43 61 71 47 63 89 53 73 6...

correct output
0 388 1949 4759 7641 8972 9293...

user output
(not available)

Test 4

Verdict: UNKNOWN

input
100
9 8 4 10 7 6 1 1 9 5 3 2 7 3 1...

correct output
0 2999 7373 6980 5935 4938 394...

user output
(not available)

Test 5

Verdict: UNKNOWN

input
100
1322 9559 309 2570 8084 6083 4...

correct output
0 4 36 120 200 433 685 901 113...

user output
(not available)

Test 6

Verdict: UNKNOWN

input
100
3630 3488 4660 4293 304 7233 9...

correct output
0 0 24 48 160 359 493 635 788 ...

user output
(not available)

Test 7

Verdict: UNKNOWN

input
100
18 63 16 54 100 65 85 8 15 45 ...

correct output
0 425 2143 4946 7602 9025 9346...

user output
(not available)

Test 8

Verdict: UNKNOWN

input
100
3 7 3 2 6 7 1 9 6 9 5 7 9 7 6 ...

correct output
0 2890 7384 7040 6051 5054 402...

user output
(not available)

Test 9

Verdict: UNKNOWN

input
100
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
0 2 7 15 26 40 57 77 100 126 1...

user output
(not available)

Test 10

Verdict: UNKNOWN

input
100
1 10000 2 10000 3 10000 4 1000...

correct output
0 2 11 27 50 80 117 161 212 27...

user output
(not available)

Test 11

Verdict: UNKNOWN

input
100
9998 9999 9999 10000 9994 9998...

correct output
0 4 12 24 40 60 84 112 144 180...

user output
(not available)

Test 12

Verdict: UNKNOWN

input
100
9997 9997 9992 10000 9998 9991...

correct output
0 4 12 24 40 60 84 112 144 180...

user output
(not available)

Test 13

Verdict: UNKNOWN

input
100
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 ...

correct output
0 100 200 300 400 500 600 700 ...

user output
(not available)

Test 14

Verdict: UNKNOWN

input
100
9995 9995 9998 9999 9999 9991 ...

correct output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

user output
(not available)

Test 15

Verdict: UNKNOWN

input
100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

user output
(not available)