Task: | Habitat |
Sender: | Pohjantahti |
Submission time: | 2018-09-27 19:01:24 +0300 |
Language: | C++ |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.02 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.43 s | details |
#4 | ACCEPTED | 0.27 s | details |
#5 | ACCEPTED | 0.59 s | details |
#6 | ACCEPTED | 0.55 s | details |
#7 | ACCEPTED | 0.43 s | details |
#8 | ACCEPTED | 0.27 s | details |
#9 | ACCEPTED | 0.51 s | details |
#10 | ACCEPTED | 0.50 s | details |
#11 | TIME LIMIT EXCEEDED | -- | details |
#12 | ACCEPTED | 0.77 s | details |
#13 | ACCEPTED | 0.51 s | details |
#14 | ACCEPTED | 0.02 s | details |
#15 | ACCEPTED | 0.15 s | details |
Code
#pragma GCC optimize("O3") #pragma GCC target("arch=skylake") #include <iostream> using namespace std; typedef long long ll; const int N = 100; int n; int t[N+5][N+5]; int miv = 1000000005; int miy = -1, mix = -1; int smv = 1000000005; int smy = -1, smx = -1; 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) { if (k >= 2*n-2) { if (y == miy && x == mix) { return smv <= k; } return miv <= 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]; int cv = t[i][j]; if (cv <= miv) { smv = miv; smx = mix; smy = miy; miv = cv; mix = j; miy = i; } } } 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: ACCEPTED
input |
---|
2 1 4 2 3 |
correct output |
---|
0 2 2 1 0 |
user output |
---|
0 2 2 1 0 |
Test 2
Verdict: ACCEPTED
input |
---|
1 1 |
correct output |
---|
0 0 |
user output |
---|
0 0 |
Test 3
Verdict: ACCEPTED
input |
---|
100 56 7 43 61 71 47 63 89 53 73 6... |
correct output |
---|
0 388 1949 4759 7641 8972 9293... |
user output |
---|
0 388 1949 4759 7641 8972 9293... |
Test 4
Verdict: ACCEPTED
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 |
---|
0 2999 7373 6980 5935 4938 394... |
Test 5
Verdict: ACCEPTED
input |
---|
100 1322 9559 309 2570 8084 6083 4... |
correct output |
---|
0 4 36 120 200 433 685 901 113... |
user output |
---|
0 4 36 120 200 433 685 901 113... |
Test 6
Verdict: ACCEPTED
input |
---|
100 3630 3488 4660 4293 304 7233 9... |
correct output |
---|
0 0 24 48 160 359 493 635 788 ... |
user output |
---|
0 0 24 48 160 359 493 635 788 ... |
Test 7
Verdict: ACCEPTED
input |
---|
100 18 63 16 54 100 65 85 8 15 45 ... |
correct output |
---|
0 425 2143 4946 7602 9025 9346... |
user output |
---|
0 425 2143 4946 7602 9025 9346... |
Test 8
Verdict: ACCEPTED
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 |
---|
0 2890 7384 7040 6051 5054 402... |
Test 9
Verdict: ACCEPTED
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 |
---|
0 2 7 15 26 40 57 77 100 126 1... |
Test 10
Verdict: ACCEPTED
input |
---|
100 1 10000 2 10000 3 10000 4 1000... |
correct output |
---|
0 2 11 27 50 80 117 161 212 27... |
user output |
---|
0 2 11 27 50 80 117 161 212 27... |
Test 11
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 9998 9999 9999 10000 9994 9998... |
correct output |
---|
0 4 12 24 40 60 84 112 144 180... |
user output |
---|
(empty) |
Test 12
Verdict: ACCEPTED
input |
---|
100 9997 9997 9992 10000 9998 9991... |
correct output |
---|
0 4 12 24 40 60 84 112 144 180... |
user output |
---|
0 4 12 24 40 60 84 112 144 180... |
Test 13
Verdict: ACCEPTED
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 |
---|
0 100 200 300 400 500 600 700 ... |
Test 14
Verdict: ACCEPTED
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 |
---|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
Test 15
Verdict: ACCEPTED
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 |
---|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |