QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#523087 | #360. Cultivation | Unforgettablepl | 5 | 28ms | 3888kb | C++20 | 1.6kb | 2024-08-17 20:07:24 | 2024-08-17 20:07:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// #define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int r,c,n;
cin >> r >> c >> n;
vector<pair<int,int>> points(n);
for(auto&[a,b]:points)cin>>a>>b;
int tar = r*c;
auto check = [&](int chosenR,int chosenC){
vector grid(2*r+1,vector(2*c+1,0));
for(auto&[x,y]:points) {
grid[x][y]++;
grid[x+chosenR][y]--;
grid[x][y+chosenC]--;
grid[x+chosenR][y+chosenC]++;
}
for(int i=1;i<=2*r;i++) {
for(int j=1;j<=2*c;j++) {
grid[i][j]+=grid[i][j-1];
}
}
for(int i=1;i<=2*c;i++) {
for(int j=1;j<=2*r;j++) {
grid[j][i]+=grid[j-1][i];
}
}
for(int i=1;i<=2*r;i++) {
for(int j=1;j<=2*c;j++) {
grid[i][j]=min(1,grid[i][j])+grid[i-1][j]+grid[i][j-1]-grid[i-1][j-1];
}
}
auto get = [&](int x1,int y1,int x2,int y2) {
return grid[x2][y2]-grid[x1-1][y2]-grid[x2][y1-1]+grid[x1-1][y1-1];
};
for(int i=1;i<=chosenR;i++) {
for(int j=1;j<=chosenC;j++) {
if(get(i,j,i+r-1,j+c-1)==tar)return true;
}
}
return false;
};
int ans = r+c;
for(int R=1;R<=r;R++) {
for(int C=1;C<=c;C++) {
if(check(R,C)) {
ans=min(ans,R+C-2);
}
}
}
cout << ans << '\n';
}
詳細信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 3608kb
input:
2 4 2 1 1 1 4
output:
3
result:
ok single line: '3'
Test #2:
score: 5
Accepted
time: 0ms
memory: 3568kb
input:
4 1 1 2 1
output:
3
result:
ok single line: '3'
Test #3:
score: 5
Accepted
time: 0ms
memory: 3576kb
input:
3 3 3 1 2 1 3 3 3
output:
3
result:
ok single line: '3'
Test #4:
score: 5
Accepted
time: 0ms
memory: 3868kb
input:
2 2 1 1 2
output:
2
result:
ok single line: '2'
Test #5:
score: 5
Accepted
time: 0ms
memory: 3644kb
input:
4 4 10 4 2 2 3 2 4 4 1 1 2 2 1 4 3 3 3 3 1 1 4
output:
2
result:
ok single line: '2'
Test #6:
score: 5
Accepted
time: 0ms
memory: 3800kb
input:
4 4 1 4 1
output:
6
result:
ok single line: '6'
Test #7:
score: 5
Accepted
time: 0ms
memory: 3668kb
input:
4 4 3 2 2 3 3 1 4
output:
5
result:
ok single line: '5'
Test #8:
score: 5
Accepted
time: 0ms
memory: 3640kb
input:
4 4 15 4 3 2 4 4 4 4 1 3 3 1 2 3 1 2 1 3 4 3 2 4 2 2 3 1 3 2 2 1 4
output:
1
result:
ok single line: '1'
Test #9:
score: 5
Accepted
time: 0ms
memory: 3580kb
input:
4 3 3 2 1 2 3 4 1
output:
3
result:
ok single line: '3'
Test #10:
score: 5
Accepted
time: 0ms
memory: 3568kb
input:
4 4 2 3 4 2 4
output:
5
result:
ok single line: '5'
Test #11:
score: 5
Accepted
time: 0ms
memory: 3632kb
input:
2 4 1 1 2
output:
4
result:
ok single line: '4'
Test #12:
score: 5
Accepted
time: 0ms
memory: 3568kb
input:
3 3 4 2 1 1 1 3 2 3 1
output:
2
result:
ok single line: '2'
Test #13:
score: 5
Accepted
time: 0ms
memory: 3576kb
input:
3 4 3 1 4 3 3 3 4
output:
4
result:
ok single line: '4'
Test #14:
score: 5
Accepted
time: 0ms
memory: 3636kb
input:
3 3 2 2 1 3 3
output:
4
result:
ok single line: '4'
Test #15:
score: 5
Accepted
time: 0ms
memory: 3628kb
input:
4 4 2 2 4 3 1
output:
6
result:
ok single line: '6'
Test #16:
score: 5
Accepted
time: 0ms
memory: 3568kb
input:
4 4 3 2 2 2 1 4 2
output:
4
result:
ok single line: '4'
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #17:
score: 10
Accepted
time: 1ms
memory: 3648kb
input:
15 15 20 6 13 14 4 11 13 15 3 12 4 10 4 11 6 8 9 12 12 2 15 4 3 8 15 8 4 3 1 5 10 11 12 8 7 13 10 11 4 1 3
output:
13
result:
ok single line: '13'
Test #18:
score: 10
Accepted
time: 6ms
memory: 3584kb
input:
25 25 66 24 6 12 18 11 2 24 18 6 9 20 6 15 19 17 2 15 9 15 20 18 9 5 19 9 2 6 12 22 16 6 2 1 5 14 24 12 21 17 24 10 15 21 1 20 22 11 24 11 4 6 21 18 12 25 20 16 3 18 16 6 4 20 9 6 15 24 14 3 20 9 9 25 9 18 6 4 16 12 7 14 22 20 25 24 10 11 14 17 6 23 23 21 12 18 22 8 23 1 11 17 18 8 5 3 7 1 17 8 12 4...
output:
9
result:
ok single line: '9'
Test #19:
score: 10
Accepted
time: 28ms
memory: 3672kb
input:
36 38 28 30 5 4 23 29 20 1 36 8 28 8 9 5 26 23 16 26 1 24 38 22 36 4 26 9 7 10 24 20 11 31 5 24 30 26 30 18 15 14 1 23 31 20 7 23 30 33 9 27 33 8 7 9 16 33 5
output:
30
result:
ok single line: '30'
Test #20:
score: 10
Accepted
time: 2ms
memory: 3648kb
input:
10 40 19 7 5 8 38 4 7 8 5 4 30 1 33 1 16 2 21 8 33 4 36 6 20 6 27 4 14 10 15 9 30 8 13 4 15 10 9 5 22
output:
17
result:
ok single line: '17'
Test #21:
score: 0
Wrong Answer
time: 24ms
memory: 3888kb
input:
40 30 50 19 20 18 16 34 28 5 8 28 21 24 13 7 1 28 23 28 18 12 6 3 6 18 8 40 27 22 19 23 22 8 6 9 12 16 10 27 25 26 19 4 9 40 26 21 22 10 8 5 2 30 25 12 12 3 1 24 14 5 3 4 8 19 9 21 16 6 3 38 29 27 20 37 25 36 24 22 20 29 26 30 19 16 14 3 3 39 25 5 7 20 15 13 12 33 30 27 16 25 14
output:
53
result:
wrong answer 1st lines differ - expected: '50', found: '53'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Memory Limit Exceeded
Test #45:
score: 0
Memory Limit Exceeded
input:
1000000000 1000000000 17 822413671 70423910 260075513 431043546 300945721 793553248 142848049 163787897 392462410 831950868 699005697 111397300 444396260 130450496 642691616 595456084 467968916 463598810 159764248 611476406 929313754 539645102 365153650 964108073 906780716 373514044 970118116 655138...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%