Submission #683115

#TimeUsernameProblemLanguageResultExecution timeMemory
683115Ronin13Chessboard (IZhO18_chessboard)C++14
70 / 100
385 ms4224 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define f first #define s second #define pii pair<ll,ll> #define pll pair<ll,ll> #define pb push_back #define epb emplace_back using namespace std; /* 6 8 3 3 3 3 1 2 1 2 3 4 3 4 5 5 5 5 4 3 4 3 4 4 4 4 2 1 2 1 3 6 3 6 */ int main(){ // freopen("school.in", "r", stdin); // freopen("school.out", "w", stdout); int n, k; cin >> n >> k; int x1[k + 1], x2[k + 1], y1[k + 1], y2[k + 1]; for(int i = 1; i <= k; ++i){ cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; x1[i]--; y1[i]--; x2[i]--; y2[i]--; } ll ans = 1e18 + 1; for(ll a = 1; a <n; a++){ if(n % a) continue; ll v = n / a; ll cnt = 0; if(v % 2 == 1) cnt += v * (v / 2) + (v + 1) / 2; else cnt = v * v / 2; cnt *= a * a; for(int i = 1; i <= k; i++){ int X = x1[i] / a, Y = y1[i] / a; if((X + Y) & 1) cnt++; else cnt--; } ans = min(ans, cnt); } for(ll a = 1; a <n; a++){ if(n % a) continue; ll v = n / a; ll cnt = -1; if(v % 2 == 1) cnt += v * (v / 2) + (v + 1) / 2; else cnt = v * v / 2; cnt *= a * a; for(int i = 1; i <= k; i++){ int X = x1[i] / a, Y = y1[i] / a; if((X + Y) & 1) cnt--; else cnt++; } ans = min(ans, cnt); } cout << ans; return 0; }
#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...