Submission #692909

# Submission time Handle Problem Language Result Execution time Memory
692909 2023-02-02T07:11:50 Z tolbi Chessboard (IZhO18_chessboard) C++17
47 / 100
55 ms 4944 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){
	return (((x/blok)%2)^((y/blok)%2));
}
int32_t main(){
	ios;
	int t=1;
	int tno = 0;
	if (!t) cin>>t;
	while (t-(tno++)){
		deci(n);deci(k);
		int say = 0;
		bool subt = true;
		for (int i = 2; i < n; i++) {
			if (n%i==0) subt=false;
		}
		vector<pair<pair<int,int>,pair<int,int>>> arr(k);
		for (int i = 0; i < k; i++){
			deci(x1);deci(y1);deci(x2);deci(y2);
			arr[i]={{x1,x2},{y1,y2}};
			if (x1!=x2 || y1!=y2) subt=false;
			say+=((x1-1)%2)^((y1-1)%2);
		}
		int blk = n*n/2;
		int whit = n*n-blk;
		if (subt){
			cout<<min(blk-say+k-say,say+whit-(k-say))<<endl;
			continue;
		}
		int all = 0;
		for (int i = 0; i < k; i++){
			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/i)*(n/i)/2*(i*i);
			ans=min(ans,all-say+bls-say);
			ans=min(ans,say+n*n-bls-all+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 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 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 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2260 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 12 ms 1492 KB Output is correct
4 Correct 12 ms 1748 KB Output is correct
5 Correct 15 ms 2004 KB Output is correct
6 Correct 10 ms 1364 KB Output is correct
7 Correct 3 ms 480 KB Output is correct
8 Correct 11 ms 1364 KB Output is correct
9 Correct 28 ms 3028 KB Output is correct
10 Correct 16 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 8 ms 1620 KB Output is correct
17 Correct 21 ms 4228 KB Output is correct
18 Correct 29 ms 4944 KB Output is correct
19 Correct 45 ms 4428 KB Output is correct
20 Correct 55 ms 4940 KB Output is correct
21 Correct 21 ms 4112 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 16 ms 2264 KB Output is correct
24 Correct 28 ms 4564 KB Output is correct
25 Correct 4 ms 724 KB Output is correct
26 Correct 15 ms 2912 KB Output is correct
27 Correct 26 ms 3536 KB Output is correct
28 Correct 30 ms 4824 KB Output is correct
29 Correct 8 ms 1868 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2260 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 12 ms 1492 KB Output is correct
4 Correct 12 ms 1748 KB Output is correct
5 Correct 15 ms 2004 KB Output is correct
6 Correct 10 ms 1364 KB Output is correct
7 Correct 3 ms 480 KB Output is correct
8 Correct 11 ms 1364 KB Output is correct
9 Correct 28 ms 3028 KB Output is correct
10 Correct 16 ms 1876 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 8 ms 1620 KB Output is correct
27 Correct 21 ms 4228 KB Output is correct
28 Correct 29 ms 4944 KB Output is correct
29 Correct 45 ms 4428 KB Output is correct
30 Correct 55 ms 4940 KB Output is correct
31 Correct 21 ms 4112 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 16 ms 2264 KB Output is correct
34 Correct 28 ms 4564 KB Output is correct
35 Correct 4 ms 724 KB Output is correct
36 Correct 15 ms 2912 KB Output is correct
37 Correct 26 ms 3536 KB Output is correct
38 Correct 30 ms 4824 KB Output is correct
39 Correct 8 ms 1868 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Incorrect 51 ms 4812 KB Output isn't correct
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 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 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 17 ms 2260 KB Output is correct
10 Correct 5 ms 852 KB Output is correct
11 Correct 12 ms 1492 KB Output is correct
12 Correct 12 ms 1748 KB Output is correct
13 Correct 15 ms 2004 KB Output is correct
14 Correct 10 ms 1364 KB Output is correct
15 Correct 3 ms 480 KB Output is correct
16 Correct 11 ms 1364 KB Output is correct
17 Correct 28 ms 3028 KB Output is correct
18 Correct 16 ms 1876 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 328 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 8 ms 1620 KB Output is correct
35 Correct 21 ms 4228 KB Output is correct
36 Correct 29 ms 4944 KB Output is correct
37 Correct 45 ms 4428 KB Output is correct
38 Correct 55 ms 4940 KB Output is correct
39 Correct 21 ms 4112 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 16 ms 2264 KB Output is correct
42 Correct 28 ms 4564 KB Output is correct
43 Correct 4 ms 724 KB Output is correct
44 Correct 15 ms 2912 KB Output is correct
45 Correct 26 ms 3536 KB Output is correct
46 Correct 30 ms 4824 KB Output is correct
47 Correct 8 ms 1868 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Incorrect 51 ms 4812 KB Output isn't correct
50 Halted 0 ms 0 KB -