이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define TASK ""
#define ALL(x) (x).begin(), (x).end()
using namespace std;
template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
if (a < b) {a = b; return true;} return false;
}
const int N = 1e5 + 5;
const int oo = 1e9;
const long long ooo = 1e18;
const int mod = 1e9 + 7; // 998244353;
const long double pi = acos(-1);
vector <int> p[N];
int x[N];
int y[N];
int u[N];
int v[N];
int n,k;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifdef ONLINE_JUDGE
// freopen(TASK".inp","r",stdin);
// freopen(TASK".out","w",stdout);
#endif
cin >> n >> k;
if (n <= 100 && k == 0) {
int ans = oo;
for (int i = 1; i < n; i++) if (n % i == 0) {
int d = (n / i);
mini(ans, ((d * d) >> 1) * i * i);
// cerr << d << " " << i << "\n";
}
cout << ans << "\n";
return 0;
}
for (int i = 1; i <= k; i++)
cin >> x[i] >> y[i] >> u[i] >> v[i];
long long ans = ooo;
for (int i = 1; i < n; i++) if (n % i == 0)
for (int v = 0; v < 2; v++) {
int d = (n / i);
long long res = ((1LL * d * d + v) >> 1) * i * i;
// cerr << "split: " << i << " " << v << " " << res << "\n";
for (int j = 1; j <= k; j++) {
int c = ( ((x[j] - 1) / i + (y[j] - 1) / i) & 1) ^ v;
// cerr << (x[j] - 1) << " " << (y[j] - 1) << " " << c << "\n";
res += (c > 0) ? -1 : 1;
}
mini(ans, res);
}
cout << ans;
return 0;
}
# | 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... |