이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target("avx2","popcnt","sse4","abm")
using namespace std;
#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MXN = 5005, MXM = 105;
int n, m, d;
bitset<MXN> brd[MXM][MXM], b[MXM];
int SOLVE(int X, int Y) {
FOR(i, 0, d) b[i].reset();
int ans = INT_MAX, pre = d - 1;
FOR(r, 0, d) {
{
int x = X + r, y = Y;
if (x >= d) x -= d;
FOR(i, 0, pre + 1) {
b[i] |= brd[x][y];
if (++y == d) y -= d;
}
}
bitset<MXN> now;
now.reset();
int cnt = 0;
while (cnt < d && now.count() != n + m) {
now |= b[cnt];
cnt++;
}
if (now.count() == n + m) {
ans = min(ans, (r + 1) * cnt);
pre = cnt;
}
}
return ans;
}
void miku() {
int x, y;
cin >> n >> m >> d;
FOR(i, 0, n) {
cin >> x >> y;
brd[x][y][i] = true;
}
FOR(i, 0, m) {
cin >> x >> y;
FOR(j, 0, d) {
brd[x][j][i + n] = true;
brd[j][y][i + n] = true;
}
}
int ans = INT_MAX;
FOR(i, 0, d) FOR(j, 0, d) ans = min(ans, SOLVE(i, j));
cout << ans << '\n';
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(cin.failbit);
miku();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
garden.cpp: In function 'int SOLVE(int, int)':
garden.cpp:43:39: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
43 | while (cnt < d && now.count() != n + m) {
| ~~~~~~~~~~~~^~~~~~~~
garden.cpp:47:25: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
47 | if (now.count() == n + m) {
| ~~~~~~~~~~~~^~~~~~~~
# | 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... |