QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#409518 | #6776. Garden | hmm789 | 6 | 72ms | 9440kb | C++14 | 1.2kb | 2024-05-12 10:39:23 | 2024-05-12 10:39:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 998244353
#define INF 1000000000000000000
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, m, d, x, y, ans = INF;
cin >> n >> m >> d;
vector<int> ax, bx[d];
int cy[d], by[m];
memset(cy, 0, sizeof(cy));
for(int i = 0; i < n; i++) {
cin >> x >> y;
ax.push_back(x);
cy[y]++;
}
for(int i = 0; i < m; i++) {
cin >> x >> by[i];
bx[x].push_back(i);
}
sort(ax.begin(), ax.end());
ax.erase(unique(ax.begin(), ax.end()), ax.end());
int prv = ax.back();
for(int i : ax) {
int cnt = 0;
for(int j = (prv+1)%d; j != i; j=(j+1)%d) {
for(int k : bx[j]) cy[by[k]]++;
cnt++;
}
int idx = 0, cur = 0, mx = 0;
while(cy[idx] == 0) idx++;
for(int j = (idx+1)%d; j != idx; j=(j+1)%d) {
if(cy[j]) cur = 0;
else cur++;
mx = max(mx, cur);
}
ans = min(ans, (d-cnt)*(d-mx));
for(int j = (prv+1)%d; j != i; j=(j+1)%d) {
for(int k : bx[j]) cy[by[k]]--;
}
prv = i;
}
cout << ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 15
Accepted
time: 72ms
memory: 8328kb
input:
499986 5 1979 299 1572 1897 274 119 291 206 1287 816 937 1922 1376 1676 57 1106 1706 1534 176 678 606 722 473 399 727 1682 1736 221 506 1413 1857 523 1730 1699 346 1056 1287 801 1017 314 1938 1872 189 1750 581 1846 1937 37 1840 1760 725 1465 1222 678 1203 1422 1930 1273 195 730 1930 232 1666 860 352...
output:
3900625
result:
ok single line: '3900625'
Test #2:
score: 0
Accepted
time: 58ms
memory: 8736kb
input:
499995 5 730 281 471 721 96 170 272 253 96 558 272 422 619 565 471 591 518 283 471 393 471 38 96 324 471 537 96 589 518 92 518 247 272 557 471 610 518 166 96 472 619 674 619 665 518 647 619 286 471 563 96 328 619 586 619 728 272 537 619 37 518 333 518 339 471 666 272 144 96 693 96 690 518 432 518 61...
output:
379900
result:
ok single line: '379900'
Test #3:
score: -15
Wrong Answer
time: 41ms
memory: 9440kb
input:
499991 8 5000 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4082 4150 4...
output:
3736
result:
wrong answer 1st lines differ - expected: '3527', found: '3736'
Subtask #2:
score: 6
Accepted
Test #11:
score: 6
Accepted
time: 1ms
memory: 3688kb
input:
4835 162 4 0 3 0 2 2 0 0 0 2 3 2 3 2 1 2 0 2 2 2 0 0 1 2 2 2 0 0 0 2 2 0 1 0 1 2 1 0 1 0 2 0 0 2 3 2 2 0 0 2 0 0 3 0 3 2 0 0 1 2 1 2 1 2 2 2 2 0 0 2 2 2 0 0 2 0 0 2 2 0 1 2 2 2 1 0 3 0 0 0 1 0 3 0 3 0 3 0 2 2 1 2 2 0 2 0 2 2 3 2 2 2 1 2 3 0 3 2 0 2 2 2 0 2 2 0 0 0 0 2 3 2 0 0 2 0 1 0 0 2 2 0 1 2 1 2...
output:
12
result:
ok single line: '12'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3944kb
input:
1759 3239 7 5 5 2 5 3 5 3 5 2 5 1 5 3 5 4 5 5 5 1 5 3 5 5 5 2 5 5 5 5 5 2 5 4 5 1 5 1 5 4 5 2 5 3 5 1 5 4 5 5 5 1 5 2 5 1 5 1 5 3 5 4 5 2 5 1 5 2 5 5 5 2 5 2 5 4 5 3 5 2 5 4 5 5 5 5 5 2 5 3 5 4 5 1 5 2 5 4 5 3 5 3 5 3 5 4 5 5 5 3 5 3 5 1 5 5 5 1 5 3 5 1 5 5 5 4 5 3 5 5 5 3 5 4 5 2 5 5 5 2 5 2 5 2 5 ...
output:
5
result:
ok single line: '5'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3784kb
input:
8 4992 10 8 3 8 3 8 3 8 3 8 3 8 3 8 3 8 3 9 0 2 9 6 2 4 5 2 5 6 9 0 0 3 4 7 6 6 8 9 1 5 6 4 7 3 8 1 9 7 8 6 7 6 4 9 5 9 5 7 2 6 4 9 5 5 2 5 0 2 9 9 1 1 8 9 7 9 8 3 4 1 2 3 5 1 1 6 8 4 5 4 2 2 9 2 9 1 0 4 8 2 9 7 2 4 5 5 7 5 8 3 6 2 1 0 6 2 8 9 5 1 6 4 2 4 7 2 1 1 9 2 5 3 8 1 4 9 6 9 2 9 8 5 1 9 7 5 ...
output:
10
result:
ok single line: '10'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
9 4988 10 8 1 8 1 8 1 8 1 8 1 8 1 8 1 8 1 8 1 9 4 4 9 4 0 6 7 4 2 3 9 7 5 0 9 3 9 3 8 1 9 7 9 6 4 7 5 9 4 5 4 5 7 5 4 2 6 1 6 3 8 4 0 9 4 0 7 6 5 5 4 9 8 0 3 9 7 3 6 7 9 2 5 2 8 4 6 0 3 7 9 4 2 1 0 4 0 1 8 0 7 5 8 6 9 7 5 5 7 5 0 3 3 1 8 9 7 2 3 0 3 1 7 6 7 4 2 5 0 1 7 9 3 3 3 4 9 7 9 0 7 7 5 7 8 7 ...
output:
10
result:
ok single line: '10'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3980kb
input:
7 4991 10 2 4 2 4 2 4 2 4 2 4 2 4 2 4 5 0 4 7 8 9 0 1 5 0 9 5 8 9 1 2 4 7 1 2 6 8 6 8 7 7 7 7 3 5 8 9 7 7 9 5 4 7 0 1 0 1 5 0 5 0 4 7 4 7 5 0 0 1 1 2 7 7 5 0 3 5 3 5 8 9 8 9 9 5 7 7 5 0 0 1 5 0 8 9 9 5 8 9 9 5 8 9 9 5 5 0 6 8 4 7 6 8 3 5 0 1 0 1 6 8 5 0 4 7 3 5 3 5 5 0 3 5 1 2 5 0 7 7 8 9 7 7 1 2 6 ...
output:
9
result:
ok single line: '9'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3964kb
input:
13 4984 10 7 0 4 5 4 0 4 0 6 5 6 5 6 8 7 5 4 0 7 8 4 5 7 8 6 5 1 1 1 1 9 7 0 7 5 9 8 6 8 4 1 1 5 4 0 4 1 6 2 7 2 2 8 1 1 7 0 4 3 7 0 9 5 6 9 7 2 9 5 1 3 1 0 6 2 1 5 1 2 3 2 1 5 1 1 9 9 2 9 9 3 9 8 4 3 3 0 7 2 6 5 7 9 2 2 6 0 9 2 2 2 1 2 7 9 4 0 3 2 2 2 3 2 4 9 6 5 3 9 3 5 7 8 2 5 7 9 3 2 1 3 2 0 7 3...
output:
40
result:
ok single line: '40'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
5 4990 10 0 4 7 7 2 8 3 9 6 3 1 2 4 5 5 5 9 2 5 5 8 0 8 2 5 5 9 2 4 6 5 2 5 0 8 1 9 5 4 2 8 1 1 2 9 2 5 6 4 2 4 6 1 0 8 2 9 2 1 6 5 1 5 5 4 1 1 1 4 0 5 5 1 6 1 1 8 6 1 2 4 0 8 1 8 2 9 2 8 5 9 1 1 0 4 2 1 5 1 0 5 1 5 1 9 0 1 1 5 1 9 6 1 5 9 2 4 0 5 6 1 6 4 0 4 0 4 2 4 2 8 1 9 0 9 5 8 1 9 5 1 0 1 2 4 ...
output:
70
result:
ok single line: '70'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
13 4987 10 5 8 0 5 6 8 2 0 2 4 7 7 6 7 0 4 7 7 7 0 6 0 0 5 0 8 8 6 4 1 3 3 8 6 4 1 1 3 8 6 9 9 1 3 4 1 9 9 4 1 8 6 9 9 8 6 1 3 8 6 4 1 3 3 4 1 9 9 9 9 8 6 8 6 4 1 1 3 8 6 3 3 9 9 1 3 3 3 8 6 1 3 1 3 8 6 1 3 4 1 3 3 8 6 3 3 1 3 4 1 3 3 8 6 9 9 1 3 9 9 8 6 8 6 9 9 4 1 8 6 8 6 4 1 4 1 9 9 8 6 3 3 3 3 8...
output:
56
result:
ok single line: '56'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
16 4983 10 4 8 1 3 7 6 9 1 5 7 7 2 5 2 8 0 2 4 3 8 4 8 4 4 9 9 7 8 6 7 0 5 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9 6 9...
output:
100
result:
ok single line: '100'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
4977 20 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
1
result:
ok single line: '1'
Test #21:
score: 0
Accepted
time: 1ms
memory: 3988kb
input:
3 4997 2 0 1 0 1 0 1 0 0 1 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 0 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1 0 0 1 1 1 0 0 0 1 1 0 1 1 0 0 0 1 0 1 0 0 1 0 0 0 0 1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 1 1 1 1 1 0 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 1 0 1 1 1 0 1 1 0 1 0 0 1 0 0 0 1 1 1...
output:
2
result:
ok single line: '2'
Subtask #3:
score: 0
Wrong Answer
Dependency #2:
100%
Accepted
Test #22:
score: 8
Accepted
time: 1ms
memory: 3712kb
input:
2098 2896 47 18 20 23 28 6 4 5 4 29 4 21 20 24 17 7 20 21 37 7 37 44 44 23 44 18 37 7 4 4 4 5 26 29 37 16 28 14 20 38 44 29 44 24 17 24 37 21 11 29 11 5 20 5 44 23 26 2 32 7 4 14 4 6 33 7 20 2 44 3 17 16 17 20 4 14 17 16 4 44 17 3 44 16 33 7 11 4 32 18 44 3 44 21 33 23 17 2 26 18 20 4 23 16 44 16 11...
output:
1599
result:
ok single line: '1599'
Test #23:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
2355 2645 37 24 17 10 35 10 8 24 19 1 0 1 29 20 33 3 36 3 24 1 12 24 14 20 23 10 30 10 35 10 20 3 29 10 20 10 8 24 33 10 0 10 21 24 2 20 25 24 17 1 21 10 26 20 19 1 35 10 17 3 5 24 21 3 23 10 3 24 3 3 26 20 36 24 2 1 14 1 26 3 18 10 5 10 36 20 25 20 31 3 24 3 9 24 21 24 36 10 8 24 2 10 36 10 16 1 9 ...
output:
840
result:
ok single line: '840'
Test #24:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
3 4995 50 37 16 37 16 37 16 19 40 9 15 26 18 28 23 39 19 28 5 20 46 8 46 20 23 8 37 3 14 42 14 43 5 10 35 44 29 28 14 19 49 10 31 11 47 36 14 15 40 44 3 34 32 24 9 20 6 34 26 19 44 49 25 6 22 31 12 24 12 6 8 2 46 20 8 23 42 10 42 28 43 8 44 4 0 33 25 9 42 40 21 48 10 2 4 39 49 33 45 40 35 41 10 49 1...
output:
50
result:
ok single line: '50'
Test #25:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
11 4985 50 21 35 21 35 21 35 21 35 21 35 21 35 21 35 21 35 21 35 21 35 21 35 2 32 24 16 0 28 20 13 48 3 36 36 39 10 4 10 3 29 34 39 19 11 14 22 13 18 19 24 42 34 49 31 15 7 39 19 27 11 28 8 26 47 10 20 23 0 19 28 2 32 3 24 12 25 36 0 26 4 37 28 28 11 6 16 16 43 0 5 37 28 29 5 35 17 11 20 44 49 19 11...
output:
50
result:
ok single line: '50'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
8 4990 50 6 27 6 27 6 27 6 27 6 27 6 27 6 27 6 27 11 41 38 18 0 46 8 25 49 49 1 11 4 3 35 0 3 36 11 41 24 14 42 31 31 46 7 14 27 2 13 5 8 25 36 23 43 47 39 39 27 2 26 36 11 41 35 0 49 49 40 0 28 9 17 26 49 49 16 9 29 42 10 43 17 26 10 43 29 42 32 28 47 3 16 9 40 0 37 29 15 32 31 46 10 43 19 49 48 31...
output:
47
result:
ok single line: '47'
Test #27:
score: 0
Accepted
time: 1ms
memory: 3984kb
input:
14 4986 50 8 14 11 3 23 40 16 14 8 40 23 3 11 36 16 44 16 36 11 36 23 44 12 40 12 14 11 40 42 6 19 37 29 6 28 46 2 0 40 9 44 20 21 6 14 37 10 49 2 34 22 49 2 22 14 30 46 47 21 30 2 0 36 12 3 45 1 2 43 19 32 30 26 13 17 22 25 47 36 37 38 16 41 17 34 45 15 2 13 35 21 17 38 20 29 47 45 45 22 31 44 21 3...
output:
800
result:
ok single line: '800'
Test #28:
score: 0
Accepted
time: 1ms
memory: 3928kb
input:
10 4985 50 40 47 6 32 6 11 6 37 2 47 2 16 8 37 29 32 6 37 40 37 35 19 12 49 24 1 19 19 9 14 33 0 33 20 17 2 1 44 46 24 10 22 21 7 21 39 23 30 48 41 35 19 34 21 49 13 9 4 32 4 36 4 19 4 34 21 41 31 25 44 13 36 42 49 33 0 48 23 36 4 44 46 17 2 11 19 21 38 21 39 43 31 48 13 46 26 43 5 28 27 33 20 44 14...
output:
1470
result:
ok single line: '1470'
Test #29:
score: -8
Wrong Answer
time: 1ms
memory: 3640kb
input:
8 4989 50 46 35 27 30 13 11 6 47 38 11 6 47 46 29 27 30 3 2 33 15 35 16 2 19 39 14 9 28 19 17 15 6 30 36 8 12 4 41 17 40 11 23 49 6 24 40 24 40 24 40 22 22 32 46 1 19 8 12 45 15 36 14 24 40 4 41 28 27 25 28 8 12 0 7 1 19 25 28 21 46 5 19 48 41 24 40 17 40 15 6 8 12 2 19 47 44 33 15 37 5 9 28 39 14 4...
output:
1591
result:
wrong answer 1st lines differ - expected: '1443', found: '1591'
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%