Submission #334327

#TimeUsernameProblemLanguageResultExecution timeMemory
334327amunduzbaevChessboard (IZhO18_chessboard)C++14
0 / 100
1 ms652 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define mp make_pair #define ub upper_bound #define lb lower_bound #define ll long long #define ld long double #define pii pair<int, int> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(),x.rend() #define prc(n) fixed << setprecision(n) #define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define pi acos(-1); const int inf = 1e9+7; const int N = 1e3+5; vector<pii>v; int x[N][N]; ll ans, n, k; void check(int rem){ int cnt = 0; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if((j + i)%2 == rem && !x[i][j]){ cnt++; //x[i][j] = 1; }else if((i+j) % 2 != rem && x[i][j]){ cnt++; //x[i][j] = 0; } } } ans = min((ll)cnt, ans); } void solve(){ fastios ans = inf; cin>>n>>k; if(k == 0){ cout<<(n*n)/2<<"\n"; return; } for(int i=0;i<k;i++){ int a, b, c, d; cin>>a>>b>>c>>d; --a, --b, --c, --d; for(int i=a;i<=c;i++) for(int j = b;j<=d;j++) x[i][j] = 1; } check(1); check(0); cout<<ans; return; } /* 3 3 1 3 1 3 2 3 3 3 1 1 3 1 */ int main(){ fastios int t = 1; //cin>>t; while(t--) solve(); 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...