QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#409879 | #6776. Garden | ksu_# | 14 | 1822ms | 3944kb | C++23 | 3.5kb | 2024-05-12 20:35:28 | 2024-05-12 20:35:29 |
Judging History
answer
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main(){
ll n, m, d;
cin >> n >> m >> d;
vector<pair<ll, ll>> a(n), b(m);
for(auto &i: a)
cin >> i.first >> i.second;
for(auto &i: b)
cin >> i.first >> i.second;
sort(a.begin(), a.end());
a.resize(unique(a.begin(), a.end()) - a.begin());
sort(b.begin(), b.end());
b.resize(unique(b.begin(), b.end()) - b.begin());
ll ans = d * d;
for(int a0 = 1; a0 <= d; a0++){
for(int b0 = 1; b0 <= d; b0++){
if(a0 * b0 >= ans)
continue;
bool end0 = false;
for(int i = 0; i < d && !end0; i++){
for(int j = 0; j < d; j++){
bool ok = false;
for(auto p: b){
if(j % d <= (j + b0 - 1) % d){
if(j % d <= p.first && p.first <= (j + b0 - 1) % d)
continue;
}
else{
if(p.first >= j % d || p.first <= (j + b0 - 1) % d)
continue;
}
if(i % d <= (i + a0 - 1) % d){
if(i % d <= p.second && p.second <= (i + a0 - 1) % d)
continue;
}
else{
if(p.second >= i % d || p.second <= (i + a0 - 1) % d)
continue;
}
ok = true;
break;
}
for(auto p: a){
bool flag1 = false, flag2 = false;
if(j % d <= (j + b0 - 1) % d){
if(j % d <= p.first && p.first <= (j + b0 - 1) % d)
flag1 = true;
}
else{
if(p.first >= j % d || p.first <= (j + b0 - 1) % d)
flag1 = true;
}
if(i % d <= (i + a0 - 1) % d){
if(i % d <= p.second && p.second <= (i + a0 - 1) % d)
flag2 = true;
}
else{
if(p.second >= i % d || p.second <= (i + a0 - 1) % d)
flag2 = true;
}
if(!flag1 || !flag2){
ok = true;
break;
}
}
if(!ok){
ans = a0 * b0;
end0 = true;
break;
}
}
}
}
}
cout << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
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:
result:
Subtask #2:
score: 6
Accepted
Test #11:
score: 6
Accepted
time: 1ms
memory: 3636kb
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: 3672kb
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: 2ms
memory: 3900kb
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: 2ms
memory: 3672kb
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: 3932kb
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: 2ms
memory: 3932kb
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: 2ms
memory: 3636kb
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: 2ms
memory: 3640kb
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: 3588kb
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: 0ms
memory: 3868kb
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: 0ms
memory: 3900kb
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: 8
Accepted
Dependency #2:
100%
Accepted
Test #22:
score: 8
Accepted
time: 469ms
memory: 3700kb
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: 152ms
memory: 3932kb
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: 58ms
memory: 3704kb
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: 18ms
memory: 3944kb
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: 12ms
memory: 3940kb
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: 1822ms
memory: 3636kb
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: 416ms
memory: 3936kb
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: 0
Accepted
time: 210ms
memory: 3692kb
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:
1443
result:
ok single line: '1443'
Test #30:
score: 0
Accepted
time: 474ms
memory: 3816kb
input:
50 4949 50 48 25 9 45 17 20 6 29 28 44 31 22 30 44 0 44 12 19 38 1 18 24 8 8 4 43 49 0 40 14 21 36 21 35 17 39 20 5 5 9 46 26 13 2 12 47 15 29 45 34 45 27 41 19 3 22 35 6 11 41 44 24 34 48 42 42 29 36 37 13 34 7 19 31 7 44 14 26 21 28 33 40 38 39 28 23 16 38 25 32 36 16 7 33 43 37 47 11 44 49 1 21 2...
output:
2350
result:
ok single line: '2350'
Test #31:
score: 0
Accepted
time: 99ms
memory: 3704kb
input:
52 4947 50 39 15 49 31 34 45 43 42 40 25 13 23 28 37 23 38 19 32 25 19 30 6 11 36 15 28 47 48 38 22 21 39 8 34 14 46 10 33 12 36 42 43 31 41 3 8 35 26 9 36 32 21 16 20 41 30 17 49 28 29 44 47 45 11 36 24 20 10 33 5 18 7 0 3 24 12 16 40 46 4 37 13 4 18 29 35 27 2 26 27 7 17 5 1 48 14 22 44 2 9 6 0 1 ...
output:
2500
result:
ok single line: '2500'
Subtask #4:
score: 0
Time Limit Exceeded
Dependency #3:
100%
Accepted
Test #32:
score: 16
Accepted
time: 773ms
memory: 3936kb
input:
3086 1910 47 7 32 34 32 7 28 8 32 9 17 7 28 43 10 7 32 33 13 24 15 39 10 8 15 30 19 45 15 46 15 44 13 4 28 12 10 41 19 15 13 14 17 16 15 12 17 8 13 30 17 25 10 0 19 4 0 46 13 29 28 4 33 11 17 1 19 27 17 18 0 26 17 18 0 33 0 13 15 36 32 8 17 34 13 33 10 13 10 43 17 46 19 26 32 41 15 16 33 14 17 41 10...
output:
1496
result:
ok single line: '1496'
Test #33:
score: -16
Time Limit Exceeded
input:
4282 718 76 11 11 44 3 64 39 25 35 39 30 40 32 74 42 12 42 64 27 42 43 3 30 23 32 43 53 7 30 53 64 45 30 7 66 45 65 64 13 42 54 59 53 23 53 72 23 16 27 29 66 64 54 64 9 30 2 25 74 39 53 42 43 59 45 36 30 5 11 59 11 59 66 41 52 15 30 29 45 12 64 34 61 65 39 45 39 57 39 34 3 23 43 63 54 64 4 42 27 64 ...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%