Submission #1371026
Source Code Expand
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; immutable int MAX = 3010; immutable int MAX2 = 10^^5 + 7; immutable long MOD = 10^^9 + 7; void main() { auto modinv = new long[](MAX2); modinv[0] = modinv[1] = 1; foreach(i; 2..MAX2) { modinv[i] = modinv[MOD % i] * (MOD - MOD / i) % MOD; } auto f_mod = new long[](MAX2); auto f_modinv = new long[](MAX2); f_mod[0] = f_mod[1] = 1; f_modinv[0] = f_modinv[1] = 1; foreach(i; 2..MAX2) { f_mod[i] = (i * f_mod[i-1]) % MOD; f_modinv[i] = (modinv[i] * f_modinv[i-1]) % MOD; } long comb(int n, int k) { return f_mod[n] * f_modinv[n-k] % MOD * f_modinv[k] % MOD; } auto s = readln.split.map!(to!int); auto N = s[0]; auto K = s[1]; auto X = new int[](N); auto Y = new int[](N); auto C = new int[][](MAX, MAX); foreach (i; 0..N) { s = readln.split.map!(to!int); X[i] = s[0]; Y[i] = s[1]; C[s[0]+1][s[1]+1] += 1; } foreach (i; 0..MAX) foreach (j; 0..MAX-1) C[i][j+1] += C[i][j]; foreach (j; 0..MAX) foreach (i; 0..MAX-1) C[i+1][j] += C[i][j]; int cumsum(int x1, int y1, int x2, int y2) { return C[x2+1][y2+1] - C[x2+1][y1] - C[x1][y2+1] + C[x1][y1]; } int hi = 3000; int lo = -1; long ans = 0; while (hi - lo > 1) { int mid = (hi + lo) / 2; long t_ans = 0; foreach (i; 0..MAX-mid-1) { foreach (j; 0..MAX-mid-1) { int a = cumsum(i, j, i+mid, j+mid); if (a >= K) { (t_ans += comb(a, K)) %= MOD; } } } if (t_ans > 0) { hi = mid; ans = t_ans; } else { lo = mid; } } hi.writeln; ans.writeln; }
Submission Info
Submission Time | |
---|---|
Task | D - アットコーダーモンスターズ |
User | nebukuro09 |
Language | D (LDC 0.17.0) |
Score | 0 |
Code Size | 2044 Byte |
Status | WA |
Exec Time | 995 ms |
Memory | 41852 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 10 | 0 / 90 | ||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt |
Subtask1 | subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask1_random01.txt, subtask1_random02.txt, subtask1_random03.txt, subtask1_random04.txt, subtask1_random05.txt, subtask1_random06.txt, subtask1_random07.txt, subtask1_random08.txt, subtask1_random09.txt, subtask1_random10.txt |
All | subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask1_random01.txt, subtask1_random02.txt, subtask1_random03.txt, subtask1_random04.txt, subtask1_random05.txt, subtask1_random06.txt, subtask1_random07.txt, subtask1_random08.txt, subtask1_random09.txt, subtask1_random10.txt, subtask2_random01.txt, subtask2_random02.txt, subtask2_random03.txt, subtask2_random04.txt, subtask2_random05.txt, subtask2_random06.txt, subtask2_random07.txt, subtask2_random08.txt, subtask2_random09.txt, subtask2_random10.txt, subtask2_random11.txt, subtask2_random12.txt, subtask2_random13.txt, subtask2_random14.txt, subtask2_random15.txt, subtask2_random16.txt, subtask2_random17.txt, subtask2_random18.txt, subtask2_random19.txt, subtask2_random20.txt, subtask2_special01.txt, subtask2_special02.txt, subtask2_special03.txt, subtask2_special04.txt, subtask2_special05.txt, subtask2_special06.txt, subtask2_special07.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask0_sample_01.txt | AC | 465 ms | 38140 KB |
subtask0_sample_02.txt | AC | 455 ms | 38524 KB |
subtask0_sample_03.txt | AC | 465 ms | 39036 KB |
subtask0_sample_04.txt | AC | 465 ms | 39164 KB |
subtask1_random01.txt | AC | 502 ms | 39804 KB |
subtask1_random02.txt | AC | 466 ms | 39164 KB |
subtask1_random03.txt | AC | 464 ms | 39804 KB |
subtask1_random04.txt | AC | 464 ms | 39804 KB |
subtask1_random05.txt | WA | 463 ms | 39932 KB |
subtask1_random06.txt | WA | 503 ms | 39036 KB |
subtask1_random07.txt | AC | 463 ms | 39292 KB |
subtask1_random08.txt | AC | 465 ms | 39932 KB |
subtask1_random09.txt | AC | 501 ms | 39804 KB |
subtask1_random10.txt | AC | 466 ms | 40060 KB |
subtask2_random01.txt | AC | 470 ms | 41468 KB |
subtask2_random02.txt | WA | 211 ms | 40060 KB |
subtask2_random03.txt | WA | 196 ms | 41340 KB |
subtask2_random04.txt | WA | 202 ms | 40828 KB |
subtask2_random05.txt | WA | 212 ms | 40700 KB |
subtask2_random06.txt | AC | 344 ms | 40316 KB |
subtask2_random07.txt | AC | 187 ms | 41340 KB |
subtask2_random08.txt | AC | 463 ms | 41468 KB |
subtask2_random09.txt | WA | 189 ms | 41340 KB |
subtask2_random10.txt | AC | 269 ms | 39932 KB |
subtask2_random11.txt | WA | 781 ms | 39932 KB |
subtask2_random12.txt | AC | 796 ms | 40060 KB |
subtask2_random13.txt | WA | 932 ms | 39932 KB |
subtask2_random14.txt | AC | 801 ms | 41084 KB |
subtask2_random15.txt | AC | 786 ms | 41212 KB |
subtask2_random16.txt | AC | 553 ms | 41340 KB |
subtask2_random17.txt | WA | 554 ms | 41596 KB |
subtask2_random18.txt | AC | 552 ms | 41212 KB |
subtask2_random19.txt | WA | 553 ms | 41852 KB |
subtask2_random20.txt | WA | 550 ms | 40444 KB |
subtask2_special01.txt | WA | 185 ms | 40188 KB |
subtask2_special02.txt | AC | 243 ms | 40956 KB |
subtask2_special03.txt | AC | 995 ms | 41212 KB |
subtask2_special04.txt | AC | 508 ms | 40572 KB |
subtask2_special05.txt | AC | 508 ms | 40316 KB |
subtask2_special06.txt | AC | 511 ms | 41340 KB |
subtask2_special07.txt | AC | 512 ms | 41724 KB |