답안 #90098

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
90098 2018-12-20T08:12:37 Z Atashka01 Chessboard (IZhO18_chessboard) C++11
8 / 100
89 ms 1992 KB
//Euzibillahiminesseqtanirracim Bismillahirrahmanirrahim

/*
ID:
TASK:
LANG: C++
*/

#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define PII pair<int,int>
#define inf 1000000001
using namespace std;

int n, m, ans = inf , r;

double l;

PII d[100001];

vector<int>v;

void f(int e1,int q1,int e2,int q2){
	
	for(auto e:v){
		
		e *= 2;
		
		if( (e1%e < e/2 && q1%e < e/2) || (e1%e >= e/2 && q1%e >= e/2) ){
			
			d[e].ff--;
			d[e].ss++;
			
		}
		else{
			
			d[e].ff++;
			d[e].ss--;
			
		}
		
	}		
	
}

int e1, q1, e2, q2;

int main()
{
	
	cin>>n>>m;
	
	v.pb(1);
	
	for(int i=2;i<=sqrt(n);i++) if(n%i == 0){
		
		v.pb(i);
		v.pb(n/i);
		
	}
	
	r = sqrt(n);
	l = sqrt(n);
	
	if(l == r) v.pop_back();
	
	for(auto e:v){
		
		d[e].ff = (( (n/e)*(n/e) )/ 2 + ( (n/e)*(n/e) )% 2 ) * e*e;
		d[e].ss = n*n - d[e].ff;
		
	}
	
	
	while(m--){
		
		cin>>e1>>q1>>e2>>q2;
		
		f(e1 - 1,q1 - 1,e2 - 1,q2 - 1);
		
		
	}
	
	for(auto e:v){
		
		ans = min(ans , min( d[e].ff , d[e].ss ));
		
	}
	
	cout<<ans;
	
}

/*
_________oBBBBB8o   oBBBBBBB8
_____o8BBBBBBBBBBB  BBBBBBBBB8        o88o
___o8BBBBBB**8BBBB  BBBBBBBBBB     oBBBBBBBo
__oBBBBBBB*   ***   BBBBBBBBBB     BBBBBBBBBBo
_8BBBBBBBBBBooooo   *BBBBBBB8      *BB* 8BBBBBBo
_8BBBBBBBBBBBBBBBB8ooBBBBBBB8           8BBBBBBB8
__*BBBBBBBBBBBBBBBBBBBBBBBBBB8 o88BB88BBBBBBBBBBBB
____*BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB8
______**8BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB*
___________*BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB8*
____________*BBBBBBBBBBBBBBBBBBBBBBBB8888**
_____________BBBBBBBBBBBBBBBBBBBBBBB*
_____________*BBBBBBBBBBBBBBBBBBBBB*
______________*BBBBBBBBBBBBBBBBBB8
_______________*BBBBBBBBBBBBBBBB*
________________8BBBBBBBBBBBBBBB8
_________________8BBBBBBBBBBBBBBBo
__________________BBBBBBBBBBBBBBB8
__________________BBBBBBBBBBBBBBBB
__________________8BBBBBBBBBBBBBBB8
__________________*BBBBBBBBBBBBBBBB
__________________8BBBBBBBBBBBBBBBB8
_________________oBBBBBBBBBBBBBBBBBB
________________oBBBBBBBBBBBBBBBBBBB
________________BBBBBBBBBBBBBBBBBBBB
_______________8BBBBBBBBBBBBBBBBBBB8
______________oBBBBBBBBB88BBBBBBBBB8
______________8BBBBBBBBB*8BBBBBBBBB*
______________BBBBBBBBB* BBBBBBBBB8
______________BBBBBBBB8 oBBBBBBBBB*
______________8BBBBBBB  oBBBBBBBB*
______________BBBBBBB*  8BBBBBBB*
_____________8BBBBBB*   BBBBBBB*
____________8BBBBBB8   oBBBBBB8
___________8BBBBBB8    8BBBBBB*
__________oBBBBBB8    BBBBBBB8
__________BBBBBBB8   BBBBBBBB*
_________oBBBBBBB8   BBBBBBBB
_________8BBBBBB8    BBBBBBB*
_________BBBBBB*     8BBBBB*
________oBBBB8       BBBBB*
________oBBB8        BBBB*
________BBBB8       8BBBBo
_______8BBBB*      oBBBBBBo
______8BBBB*       *BBBBBBBB8o
______BBBBB*            *88BBBo
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 2 ms 584 KB Output is correct
8 Correct 2 ms 584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 89 ms 1992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 89 ms 1992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 2 ms 584 KB Output is correct
8 Correct 2 ms 584 KB Output is correct
9 Incorrect 89 ms 1992 KB Output isn't correct
10 Halted 0 ms 0 KB -