QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#109785 | #360. Cultivation | bashkort# | 0 | 1ms | 3876kb | C++20 | 1.8kb | 2023-05-30 16:56:52 | 2024-05-31 13:50:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int R, C, n;
cin >> R >> C >> n;
vector<int> x(n), y(n);
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
--x[i], --y[i];
}
int ans = R + C;
for (int k = 0; k < 2; ++k) {
for (int u = 0; u < R; ++u) {
for (int d = 0; d + u < R; ++d) {
vector<vector<int>> a(R);
for (int i = 0; i < n; ++i) {
for (int t = d; t >= -u; --t) {
if (x[i] + t >= 0 && x[i] + t < R) {
a[x[i] + t].push_back(y[i]);
}
}
}
int mxx = 0, mxy = 0, mxs = 0;
bool ok = true;
for (int i = 0; i < R; ++i) {
sort(a[i].begin(), a[i].end());
a[i].resize(unique(a[i].begin(), a[i].end()) - a[i].begin());
if (a[i].empty()) {
ok = false;
} else {
mxx = max(mxx, a[i][0]);
mxy = max(mxy, C - a[i][1] - 1);
for (int j = 0; j + 1 < size(a[i]); ++j) {
mxs = max(mxs, a[i][j + 1] - a[i][j] - 1);
}
}
}
if (ok) {
ans = min(ans, max(mxx + mxy, mxs) + u + d);
}
}
}
for (int i = 0; i < n; ++i) {
swap(x[i], y[i]);
}
swap(R, C);
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3876kb
input:
2 4 2 1 1 1 4
output:
2
result:
wrong answer 1st lines differ - expected: '3', found: '2'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Time Limit Exceeded
Test #45:
score: 0
Time 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%