Submission #378577

# Submission time Handle Problem Language Result Execution time Memory
378577 2021-03-17T01:55:39 Z hhhhaura Chessboard (IZhO18_chessboard) C++14
8 / 100
33 ms 3180 KB
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define ceil(a, b) ((a + b - 1) / (b))
#define all(x) x.begin(), x.end()

#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
#define MAXN 1000005

#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

using namespace std;
#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a...)
void vprint(auto L, auto R) {
	while(L < R) cerr << *L << " \n"[next(L) == R], ++ L;
}
void kout() {cerr << endl;}
template<class T1, class ... T2> void kout(T1 a, T2 ... e) {
	cerr << a << " ", kout(e...);
}
#else 
#define print(...) 0
#define vprint(...) 0
#endif
struct sb2 {
	int n, k;
	struct pt {
		int u, l, d, r;
	};
	vector<pt> a;
	void init_(int _n, int _k) {
		n = _n, k = _k;
		a.assign(k + 1, {0, 0, 0, 0});
	}
	int solve() {
		int ans[2];
		ans[0] = ans[1] = 0;
		rep(i, 1, k) {
			int x, y;
			x = a[i].u, y = a[i].l;
			if((x & 1) == (y & 1)) ans[0] ++;
			else ans[1] ++;
		}
		int cnt1 = ceil(n, 2) * ceil(n, 2) + (n / 2) * (n / 2);
		int aa = cnt1 - ans[0] + ans[1];
		int bb = n * n - cnt1 - ans[1] + ans[0];
		return min(aa, bb);
	}

} ac;
struct sb1 {
	int n, k;
	struct pt {
		int u, l, d, r;
	};
	vector<pt> a;
	void init_(int _n, int _k) {
		n = _n, k = _k;
		a.assign(k + 1, {0, 0, 0, 0});
	}
	int solve() {
		int ans = INF;
		rep(i, 1, n - 1) {
			if(n % i) continue;
			int cnt = 0;
			rep(j, 1, n / i) rep(m, 1, n / i) {
				cnt += i * i * bool((j & 1) == (m & 1));
			}
			ans = min(ans, n * n - cnt);
		}
		return ans;
	}

} ;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n, k; cin >> n >> k;
	ac.init_(n, k);
	rep(i, 1, k) {
		cin >> ac.a[i].u >> ac.a[i].l;
		cin >> ac.a[i].d >> ac.a[i].r;
	}
	cout << ac.solve() << "\n";
	return 0;
}

Compilation message

chessboard.cpp:4: warning: ignoring #pragma loop  [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
chessboard.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts'
   24 | void vprint(auto L, auto R) {
      |             ^~~~
chessboard.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts'
   24 | void vprint(auto L, auto R) {
      |                     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2284 KB Output is correct
2 Correct 6 ms 876 KB Output is correct
3 Correct 15 ms 1652 KB Output is correct
4 Correct 16 ms 1772 KB Output is correct
5 Correct 20 ms 2028 KB Output is correct
6 Correct 13 ms 1388 KB Output is correct
7 Correct 3 ms 620 KB Output is correct
8 Correct 13 ms 1388 KB Output is correct
9 Correct 33 ms 3180 KB Output is correct
10 Correct 19 ms 1900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2284 KB Output is correct
2 Correct 6 ms 876 KB Output is correct
3 Correct 15 ms 1652 KB Output is correct
4 Correct 16 ms 1772 KB Output is correct
5 Correct 20 ms 2028 KB Output is correct
6 Correct 13 ms 1388 KB Output is correct
7 Correct 3 ms 620 KB Output is correct
8 Correct 13 ms 1388 KB Output is correct
9 Correct 33 ms 3180 KB Output is correct
10 Correct 19 ms 1900 KB Output is correct
11 Incorrect 1 ms 364 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -