QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#557042 | #360. Cultivation | makrav | 0 | 0ms | 3600kb | C++20 | 1.9kb | 2024-09-11 00:51:18 | 2024-09-11 00:51:18 |
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second
void solve() {
int h, w, n; cin >> h >> w >> n;
vector<pair<int, int>> a(n);
for (int i = 0; i < n; i++) {a[i].first--; a[i].second--; cin >> a[i].first >> a[i].second; }
int ans = 1e9;
for (int up = 0; up < h; up++) {
for (int down = 0; down < h; down++) {
for (int left = 0; left < w; left++) {
for (int right = 0; right < w; right++) {
vector<vector<int>> us(h, vector<int>(w));
for (int i = 0; i < n; i++) {
for (int j=-up;j<=down;j++){
for (int k = -left; k <= right; k++) {
if (a[i].first + j >= 0 && a[i].first + j < h && a[i].second + k >= 0 && a[i].second + k < w) us[a[i].first + j][a[i].second + k] = 1;
}
}
}
bool good = true;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if (!us[i][j]){
good = false;
break;
}
}
}
if(good)ans=min(ans,up+down+left+right);
}
}
}
}
cout << ans << '\n';
}
signed main() {
int tt = 1;
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
cin >> tt;
#else
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#endif
while (tt--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 3564kb
input:
2 4 2 1 1 1 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 3600kb
input:
4 1 1 2 1
output:
1000000000
result:
wrong answer 1st lines differ - expected: '3', found: '1000000000'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
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:
0%