답안 #43884

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43884 2018-03-27T06:01:16 Z Tenuun Chessboard (IZhO18_chessboard) C++17
31 / 100
198 ms 15328 KB
#include<bits/stdc++.h>

using namespace std;

int main(){
	int n, k, x, y, x1, y1, res=INT_MAX;
	cin >> n >> k;
	vector<int>fac;
	map<int, int>map;
	for(int i=1; i<n; i++){
		if(n%i==0){
			fac.push_back(i);
		}
	}
	if(k==0){
		int res;
		int i=fac.size()-1;
		if(n/fac[i]%2){	
			res=(n*n-fac[i]*fac[i])/2;	
		}
		else{
			res=(n*n)/2;
		}
		cout << res;
		return 0;
	}
	for(int j=0; j<k; j++){
		cin >> x >> y >> x1 >> y1;
		for(int i=0; i<fac.size(); i++){
			if((x%(2*fac[i])>=1 && x%(2*fac[i])<=fac[i] && y%(2*fac[i])<=fac[i]&&y%(2*fac[i])>=1) ||((x%(2*fac[i])==0 || x%(2*fac[i])>fac[i]) && (y%(2*fac[i])>fac[i]||y%(2*fac[i])==0)) )map[i+1]++;
		}
	}
	int i=0;
	for (auto it=map.begin(); it!=map.end(); ++it){
		int res1, res2;
		i=it->first-1;
		//cout << it->first << it->second << endl;
		if(n/fac[i]%2){	
			res1=(n*n-fac[i]*fac[i])/2+fac[i]*fac[i]-it->second+k-it->second;
			res2=it->second+(n*n-fac[i]*fac[i])/2-(k-it->second);
			res2=n*n-res1;
			//cout << it->second << " " << res1 << " " << res2 << endl;	
		}
		else{
			res1=(n*n)/2-it->second+k-it->second;
			res2=n*n-res1;
		}
		res=min(res, res1);
		res=min(res, res2);
		i++;
	}
	cout << res;
    return 0;
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:29:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<fac.size(); i++){
                ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 728 KB Output is correct
2 Correct 2 ms 956 KB Output is correct
3 Correct 2 ms 956 KB Output is correct
4 Correct 4 ms 956 KB Output is correct
5 Correct 3 ms 956 KB Output is correct
6 Correct 2 ms 1136 KB Output is correct
7 Correct 3 ms 1136 KB Output is correct
8 Correct 2 ms 1136 KB Output is correct
9 Correct 2 ms 1136 KB Output is correct
10 Correct 2 ms 1136 KB Output is correct
11 Correct 2 ms 1136 KB Output is correct
12 Correct 2 ms 1136 KB Output is correct
13 Correct 3 ms 1140 KB Output is correct
14 Correct 3 ms 1140 KB Output is correct
15 Correct 3 ms 1140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 728 KB Output is correct
2 Correct 2 ms 956 KB Output is correct
3 Correct 2 ms 956 KB Output is correct
4 Correct 4 ms 956 KB Output is correct
5 Correct 3 ms 956 KB Output is correct
6 Correct 2 ms 1136 KB Output is correct
7 Correct 3 ms 1136 KB Output is correct
8 Correct 2 ms 1136 KB Output is correct
9 Correct 2 ms 1136 KB Output is correct
10 Correct 2 ms 1136 KB Output is correct
11 Correct 2 ms 1136 KB Output is correct
12 Correct 2 ms 1136 KB Output is correct
13 Correct 3 ms 1140 KB Output is correct
14 Correct 3 ms 1140 KB Output is correct
15 Correct 3 ms 1140 KB Output is correct
16 Correct 34 ms 1556 KB Output is correct
17 Correct 102 ms 2892 KB Output is correct
18 Correct 142 ms 4644 KB Output is correct
19 Correct 184 ms 5956 KB Output is correct
20 Correct 198 ms 7544 KB Output is correct
21 Correct 91 ms 8828 KB Output is correct
22 Correct 3 ms 8848 KB Output is correct
23 Correct 57 ms 9488 KB Output is correct
24 Correct 106 ms 11060 KB Output is correct
25 Correct 14 ms 11076 KB Output is correct
26 Correct 67 ms 12108 KB Output is correct
27 Correct 84 ms 13168 KB Output is correct
28 Correct 110 ms 14652 KB Output is correct
29 Correct 39 ms 15300 KB Output is correct
30 Correct 5 ms 15328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -