Submission #488351

#TimeUsernameProblemLanguageResultExecution timeMemory
488351levsog2004Chessboard (IZhO18_chessboard)C++14
70 / 100
207 ms2508 KiB
#include <iostream> #include <iomanip> #include <fstream> #include <algorithm> #include <cstring> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <cmath> #include <list> #include <set> #include <map> using namespace std; typedef long long ll; #define all(x) x.begin(),x.end() #define al(a,n) (a,a+n) #define se second #define fr first #define m_p make_pair const ll N = 1005; const ll mod = 1000 * 1000 * 1000 + 7; const ll inf = 1000000009; ll n, m, k, z, t, x, y, ans, pat,a[N][N]; pair<ll, ll> p[N][N]; vector<pair<ll, ll>> v; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> x >> y >> x >> y; v.push_back({ x-1,y-1 }); } ans = inf*inf; for (int ii = 1; ii <= n/2; ++ii) { x = 0; y = 0; if (n % ii == 0) { for (int i = 0; i < m; ++i) { if ((v[i].first / ii + v[i].second / ii) % 2 == 0) { x++; } else y++; } k = n / ii; k *= k; z = k / 2; if (k % 2 == 1) z++; k /= 2; ans = min(ans, min(z*ii*ii-x+y,k*ii*ii-y+x)); } } cout << ans << endl; 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...