Submission #692517

# Submission time Handle Problem Language Result Execution time Memory
692517 2023-02-01T17:36:30 Z tolbi Chessboard (IZhO18_chessboard) C++17
39 / 100
52 ms 4956 KB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
#ifdef LOCAL
	#include "23.h"
#endif
#define int long long
#define endl '\n'
#define vint(x) vector<int> x
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(),x.end())
#define sortrarr(x) sort(x.rbegin(),x.rend())
#define det(x) cout<<"NO\0YES"+x*3<<endl;
#define INF LONG_LONG_MAX
#define rev(x) reverse(x.begin(),x.end());
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tol(bi) (1LL<<((int)(bi)))
const int MOD = 1e9+7;
using namespace std;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
bool isblack(int blok, int x, int y){
	int kk = ((x/blok)%2+(y/blok)%2)%2;
	return kk;
}
int32_t main(){
	ios;
	int t=1;
	int tno = 0;
	if (!t) cin>>t;
	while (t-(tno++)){
		deci(n);deci(k);
		vector<pair<pair<int,int>,pair<int,int>>> arr(k);
		int all = 0;
		for (int i = 0; i < k; i++){
			cin>>arr[i].first.first>>arr[i].second.first>>arr[i].first.second>>arr[i].second.second;
			arr[i].first.first--;
			arr[i].first.second--;
			arr[i].second.first--;
			arr[i].second.second--;
			all+=(arr[i].second.second-arr[i].second.first+1)*(arr[i].first.second-arr[i].first.first+1);
		}
		int ans = MOD;
		for (int i = 1; i < n; i++){
			if (n%i) continue;
			int say = 0;
			for (int j = 0; j < k; j++){
				for (int z = arr[j].first.first; z <= arr[j].first.second; z++){
					for (int tt = arr[j].second.first; tt<=arr[j].second.second;tt++){
						say+=isblack(i,z,tt);
					}
				}
			}
			int bls = n*n;
			if ((n/i)%2){
				bls=(n/i)*(n/i)/2*(i*i);
			}
			else {
				bls/=2;
			}
			ans=min(ans,all-say+bls-say);
			bls=n*n-bls;
			say=all-say;
			ans=min(ans,all-say+bls-say);
		}
		cout<<ans<<endl;
	}
}

Compilation message

chessboard.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      |
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 3688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 8 ms 1620 KB Output is correct
17 Correct 22 ms 4240 KB Output is correct
18 Correct 27 ms 4956 KB Output is correct
19 Correct 46 ms 4500 KB Output is correct
20 Correct 52 ms 4948 KB Output is correct
21 Correct 26 ms 4124 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 13 ms 2284 KB Output is correct
24 Correct 24 ms 4532 KB Output is correct
25 Correct 3 ms 724 KB Output is correct
26 Correct 15 ms 2900 KB Output is correct
27 Correct 21 ms 3532 KB Output is correct
28 Correct 28 ms 4816 KB Output is correct
29 Correct 9 ms 1872 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 3688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 20 ms 3688 KB Output isn't correct
10 Halted 0 ms 0 KB -