답안 #1004453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1004453 2024-06-21T09:09:46 Z saturina Cultivation (JOI17_cultivation) C++14
0 / 100
0 ms 348 KB
#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

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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -