This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) for (int i = 1; i <= (n); i++)
#define REP0(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define printclock cerr << "\nTime : " << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms\n";
#define int long long
const int mod = 1e9 + 7, mxn = 305;
int r, c, n;
int32_t main()
{
#define task ""
if (fopen(task ".inp", "r"))
{
freopen(task ".inp", "r", stdin);
freopen(task ".out", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
cin >> r >> c >> n;
vector<int> r1, c1;
for (int i = 1; i <= n; ++i)
{
int x, y;
cin >> x >> y;
r1.pb(x);
c1.pb(y);
}
sort(begin(r1), end(r1));
sort(begin(c1), end(c1));
int d = 0, e = 0;
REP(i, n - 1)
d = max(d, r1[i] - r1[i - 1] - 1);
d = max({d, r - r1[n - 1], r1[0] - 1});
REP(i, n - 1)
e = max(e, c1[i] - c1[i - 1] - 1);
e = max({e, c - c1[n - 1], c1[0] - 1});
cout << e + d << '\n';
return 0;
}
Compilation message (stderr)
cultivation.cpp: In function 'int32_t main()':
cultivation.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
17 | freopen(task ".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cultivation.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | freopen(task ".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |