제출 #151480

#제출 시각아이디문제언어결과실행 시간메모리
151480nvmdavaChessboard (IZhO18_chessboard)C++17
100 / 100
259 ms2716 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...