답안 #371608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
371608 2021-02-27T03:21:19 Z S920105123 Monochrome Points (JOI20_monochrome) C++14
25 / 100
2000 ms 512 KB
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define all_of(v) (v).begin(), (v).end()
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define fi first
#define se second
const int MAXN = 200005;
//const LL INF = (LL) 1e9 + 8763;
//const LL MOD = (LL) 1e9 + 7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, arr[MAXN];
vector<int> W, B;

LL check2(int d) {
	int res = 0;
	for (int i = 0; i < n; i++) {
		int mat1 = (i + d) % n;
		for (int j = 0; j < i; j++) {
			int mat2 = (j + d) % n;
			int l1 = W[i], r1 = B[mat1];
			int l2 = W[j], r2 = B[mat2];
			if (l1 > r1) swap(l1, r1);
			int in1 = (l1 <= l2 && l2 <= r1), in2 = (l1 <= r2 && r2 <= r1);
			res += (in1 != in2);
		}
	}
	return res;
}

void solve() {
	cin >> n;
	for (int i = 0; i < 2 * n; i++) {
		char ch;
		cin >> ch;
		arr[i] = (ch == 'B');
		if (arr[i]) B.push_back(i);
		else W.push_back(i);
	}
	
	LL ans = 0;
//	for (int d = 0; d < n; d++) {
//		ans = max(ans, check(d));
//	}
	for (int d = 0; d < n; d++) {
		ans = max(ans, check2(d));
	}
	cout << ans << '\n';
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	int tc = 1;
//	cin >> tc;
	for (int i = 1; i <= tc; i++) {
		solve();
	}

	return 0;
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 72 ms 492 KB Output is correct
15 Correct 72 ms 364 KB Output is correct
16 Correct 69 ms 384 KB Output is correct
17 Correct 72 ms 364 KB Output is correct
18 Correct 53 ms 364 KB Output is correct
19 Correct 57 ms 364 KB Output is correct
20 Correct 60 ms 384 KB Output is correct
21 Correct 49 ms 364 KB Output is correct
22 Correct 53 ms 492 KB Output is correct
23 Correct 20 ms 364 KB Output is correct
24 Correct 52 ms 364 KB Output is correct
25 Correct 47 ms 364 KB Output is correct
26 Correct 51 ms 364 KB Output is correct
27 Correct 57 ms 364 KB Output is correct
28 Correct 68 ms 364 KB Output is correct
29 Correct 50 ms 364 KB Output is correct
30 Correct 56 ms 364 KB Output is correct
31 Correct 72 ms 492 KB Output is correct
32 Correct 72 ms 364 KB Output is correct
33 Correct 72 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 72 ms 492 KB Output is correct
15 Correct 72 ms 364 KB Output is correct
16 Correct 69 ms 384 KB Output is correct
17 Correct 72 ms 364 KB Output is correct
18 Correct 53 ms 364 KB Output is correct
19 Correct 57 ms 364 KB Output is correct
20 Correct 60 ms 384 KB Output is correct
21 Correct 49 ms 364 KB Output is correct
22 Correct 53 ms 492 KB Output is correct
23 Correct 20 ms 364 KB Output is correct
24 Correct 52 ms 364 KB Output is correct
25 Correct 47 ms 364 KB Output is correct
26 Correct 51 ms 364 KB Output is correct
27 Correct 57 ms 364 KB Output is correct
28 Correct 68 ms 364 KB Output is correct
29 Correct 50 ms 364 KB Output is correct
30 Correct 56 ms 364 KB Output is correct
31 Correct 72 ms 492 KB Output is correct
32 Correct 72 ms 364 KB Output is correct
33 Correct 72 ms 420 KB Output is correct
34 Execution timed out 2065 ms 512 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 72 ms 492 KB Output is correct
15 Correct 72 ms 364 KB Output is correct
16 Correct 69 ms 384 KB Output is correct
17 Correct 72 ms 364 KB Output is correct
18 Correct 53 ms 364 KB Output is correct
19 Correct 57 ms 364 KB Output is correct
20 Correct 60 ms 384 KB Output is correct
21 Correct 49 ms 364 KB Output is correct
22 Correct 53 ms 492 KB Output is correct
23 Correct 20 ms 364 KB Output is correct
24 Correct 52 ms 364 KB Output is correct
25 Correct 47 ms 364 KB Output is correct
26 Correct 51 ms 364 KB Output is correct
27 Correct 57 ms 364 KB Output is correct
28 Correct 68 ms 364 KB Output is correct
29 Correct 50 ms 364 KB Output is correct
30 Correct 56 ms 364 KB Output is correct
31 Correct 72 ms 492 KB Output is correct
32 Correct 72 ms 364 KB Output is correct
33 Correct 72 ms 420 KB Output is correct
34 Execution timed out 2065 ms 512 KB Time limit exceeded
35 Halted 0 ms 0 KB -