Submission #338413

#TimeUsernameProblemLanguageResultExecution timeMemory
338413BY_KUTBILIMChessboard (IZhO18_chessboard)C++14
16 / 100
37 ms1772 KiB
/** @BY_KUTBILIM **/ #include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define ll long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).end() const int inf = (int)1e9+7; bool prime(){ } int main(){ ios_base::sync_with_stdio(false); cin.tie(); int k; ll n; cin >> n >> k; int x1[k], x2[k], y1[k], y2[k]; vector<ll> div; div.pb(1); for(int i = 2; i <= sqrt(n); i++){ if(n % i == 0){ div.pb(i); if(i != n / i){ div.pb(n/i); } } } sort(all(div)); vector<ll> cnt1((int)div.size(), 0), cnt0((int)div.size(), 0); for(int i = 0; i < k; i++){ cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; for(int j = 0; j < (int)div.size(); j++){ if((x1[i] / div[j] + y1[i] / div[j]) % 2 == 0)cnt0[j]++; else cnt1[j]++; } } ll ans = n * n; for(int i = 0; i < (int)div.size(); i++){ ans = min({ans, n * n / (div[i] * div[i]) / 2ll * div[i] * div[i] + ((n * n / (div[i] * div[i]) % 2)) - cnt0[i] + cnt1[i], n * n / (div[i] * div[i]) / 2ll * div[i] * div[i] - cnt1[i] + cnt0[i]}); // cout << div[i] << " " << n * n / (div[i] * div[i]) / 2ll + ((n * n / (div[i] * div[i]) % 2)) - cnt0[i] + cnt1[i] << " " << n * n / (div[i] * div[i]) / 2ll - cnt1[i] + cnt0[i] << endl; } cout << ans; return 0; }

Compilation message (stderr)

chessboard.cpp: In function 'bool prime()':
chessboard.cpp:16:1: warning: no return statement in function returning non-void [-Wreturn-type]
   16 | }
      | ^
#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...