이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define N 200002
#define ff first
#define ss second
#define ll long long
vector<int> di;
ll dif[200005];
ll res = 0x3f3f3f3f3f3f3f3f;
int get(int x, int d){
int r = x / (2 * d) * d;
int t = x % (2 * d);
return r + min(t, d);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, k;
cin>>n>>k;
for(int i = 1; i < n; i++)
if(n % i == 0) di.push_back(i);
for(int i = 0; i < di.size(); i++)
dif[i] = 1LL * n * n - 1LL * n * n / (1LL * di[i] * di[i]) / 2 * (1LL * di[i] * di[i]);
while(k--){
int x1, x2, y1, y2;
cin>>x1>>y1>>x2>>y2;
for(int i = 0; i < di.size(); i++){
int ox, ex, oy, ey;
ex = get(x2, di[i]) - get(x1 - 1, di[i]);
ox = x2 - x1 + 1 - ex;
ey = get(y2, di[i]) - get(y1 - 1, di[i]);
oy = y2 - y1 + 1 - ey;
dif[i] -= 1LL * ex * ey + 1LL * ox * oy;
dif[i] += 1LL * ex * oy + 1LL * ey * ox;
}
}
for(int i = 0; i < di.size(); i++){
res = min(res, min(dif[i], 1LL * n * n - dif[i]));
}
cout<<res;
}
컴파일 시 표준 에러 (stderr) 메시지
chessboard.cpp: In function 'int main()':
chessboard.cpp:30:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < di.size(); i++)
~~^~~~~~~~~~~
chessboard.cpp:37:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < di.size(); i++){
~~^~~~~~~~~~~
chessboard.cpp:48:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < di.size(); i++){
~~^~~~~~~~~~~
# | 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... |