Submission #555240

#TimeUsernameProblemLanguageResultExecution timeMemory
555240ngpin04Chessboard (IZhO18_chessboard)C++14
70 / 100
334 ms6612 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define TASK "" #define ALL(x) (x).begin(), (x).end() using namespace std; template <typename T1, typename T2> bool mini(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maxi(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } const int N = 1e5 + 5; const int oo = 1e9; const long long ooo = 1e18; const int mod = 1e9 + 7; // 998244353; const long double pi = acos(-1); vector <int> p[N]; int x[N]; int y[N]; int u[N]; int v[N]; int n,k; int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifdef ONLINE_JUDGE // freopen(TASK".inp","r",stdin); // freopen(TASK".out","w",stdout); #endif cin >> n >> k; if (n <= 100 && k == 0) { int ans = oo; for (int i = 1; i < n; i++) if (n % i == 0) { int d = (n / i); mini(ans, ((d * d) >> 1) * i * i); // cerr << d << " " << i << "\n"; } cout << ans << "\n"; return 0; } for (int i = 1; i <= k; i++) cin >> x[i] >> y[i] >> u[i] >> v[i]; long long ans = ooo; for (int i = 1; i < n; i++) if (n % i == 0) for (int v = 0; v < 2; v++) { int d = (n / i); long long res = ((1LL * d * d + v) >> 1) * i * i; // cerr << "split: " << i << " " << v << " " << res << "\n"; for (int j = 1; j <= k; j++) { int c = ( ((x[j] - 1) / i + (y[j] - 1) / i) & 1) ^ v; // cerr << (x[j] - 1) << " " << (y[j] - 1) << " " << c << "\n"; res += (c > 0) ? -1 : 1; } mini(ans, res); } 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...