답안 #378514

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378514 2021-03-17T01:17:52 Z cheissmart Chessboard (IZhO18_chessboard) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;
const ll oo = 1e18;

signed main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	V<array<int, 4>> a(k);
	for(int i = 0; i < k; i++) {
		for(int j = 0; j < 4; j++)
			cin >> a[i][j], a[i][j]--;
	}

	ll ans = oo;
	auto go = [&] (int b) {
		assert(n % b == 0);
		int m = n / b;
		ll black = (ll) m * m / 2 * b * b, white = (ll) n * ns- black;
		int black_type = 1;
		for(int _ = 0; _ < 2; _++) {
			int in_black = 0, in_white = 0;
			for(int i = 0; i < k; i++) {
				int tt = a[i][0] / b + a[i][1] / b;
				if(tt % 2 == black_type) in_black++;
				else in_white++;
			}
			assert(in_black <= black);
			assert(in_white <= white);
			ans = min(ans, in_white + black - in_black);
			swap(black, white);
			black_type ^= 1;
		}
	};

	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			go(i);
			if(n / i != i && n / i != n) go(n / i);
		}
	}
	cout << ans << '\n';

}

Compilation message

chessboard.cpp: In lambda function:
chessboard.cpp:37:55: error: 'ns' was not declared in this scope; did you mean 'ans'?
   37 |   ll black = (ll) m * m / 2 * b * b, white = (ll) n * ns- black;
      |                                                       ^~
      |                                                       ans