Submission #910757

#TimeUsernameProblemLanguageResultExecution timeMemory
910757penguin133Chessboard (IZhO18_chessboard)C++17
70 / 100
209 ms5956 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int A[100005], B[100005], C[100005], D[100005]; void solve(){ int n, k; cin >> n >> k; for(int i=1;i<=k;i++)cin >> A[i] >> B[i] >> C[i] >> D[i]; int ans = 1e18; for(int i=1;i<n;i++){ if(n%i)continue; int tmp = ((n / i) * (n / i) / 2 * i * i), tmp2 = (((n / i) * (n / i) + 1) / 2 * i * i); for(int j=1;j<=k;j++){ // count number of black rows int lol = (A[j] + i - 1) / i, lol2 = (B[j] + i - 1) / i; if(lol%2 == lol2%2)tmp2--, tmp++; else tmp--, tmp2++; } //cout << i << ' ' << tmp << ' ' << tmp2 << '\n'; ans = min({ans, tmp, tmp2}); } cout << ans; } main(){ ios::sync_with_stdio(0);cin.tie(0); int tc = 1; //cin >> tc; for(int tc1=1;tc1<=tc;tc1++){ // cout << "Case #" << tc1 << ": "; solve(); } }

Compilation message (stderr)

chessboard.cpp:34:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main(){
      | ^~~~
#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...