Submission #962252

# Submission time Handle Problem Language Result Execution time Memory
962252 2024-04-13T09:44:39 Z 0npata Monochrome Points (JOI20_monochrome) C++17
25 / 100
2000 ms 604 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define vec vector
#define pi pair<int, int>
#define fst first
#define snd second
#define pb push_back

int n;
int mes(vec<pi> p) {
	int res = 0;

	for(int i = 0; i<p.size(); i++) {
		for(int j = i+1; j<p.size(); j++) {
			int l1 = p[i].fst;
			int r1 = p[i].snd;
			if(l1 > r1) swap(l1, r1);

			int l2 = p[j].fst;
			int r2 = p[j].snd;
			if(l2 > r2) swap(l2, r2);

			if(l1 < l2 && r1 > l2 && r1 < r2) res++;
			else if(l1 > l2 && l1 < r2 && r1 > r2) res++;
		}
	}

	return res;
}

int32_t main() {
	cin >> n;
	string s;
	cin >> s;

	vec<int> b(0);
	vec<int> w(0);

	for(int i = 0; i<s.size(); i++) {
		if(s[i] == 'W') {
			w.pb(i);
		}
		else {
			b.pb(i);
		}
	}

	int ans = 0;

	for(int i = 0; i<n; i++) {
		// construct possible pairings
		vec<pi> p;
		for(int j = 0; j<n; j++) {
			p.pb({w[j], b[(j+i)%n]});
		}
		int res = mes(p);

		ans = max(res, ans);
	}

	cout << ans << '\n';
}

Compilation message

monochrome.cpp: In function 'long long int mes(std::vector<std::pair<long long int, long long int> >)':
monochrome.cpp:15:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i = 0; i<p.size(); i++) {
      |                 ~^~~~~~~~~
monochrome.cpp:16:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   for(int j = i+1; j<p.size(); j++) {
      |                    ~^~~~~~~~~
monochrome.cpp: In function 'int32_t main()':
monochrome.cpp:41:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 0; i<s.size(); i++) {
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 428 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 428 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 23 ms 344 KB Output is correct
15 Correct 22 ms 348 KB Output is correct
16 Correct 21 ms 344 KB Output is correct
17 Correct 20 ms 348 KB Output is correct
18 Correct 16 ms 468 KB Output is correct
19 Correct 19 ms 468 KB Output is correct
20 Correct 17 ms 348 KB Output is correct
21 Correct 13 ms 344 KB Output is correct
22 Correct 18 ms 348 KB Output is correct
23 Correct 6 ms 348 KB Output is correct
24 Correct 13 ms 460 KB Output is correct
25 Correct 13 ms 348 KB Output is correct
26 Correct 16 ms 348 KB Output is correct
27 Correct 17 ms 464 KB Output is correct
28 Correct 18 ms 348 KB Output is correct
29 Correct 17 ms 472 KB Output is correct
30 Correct 16 ms 344 KB Output is correct
31 Correct 20 ms 348 KB Output is correct
32 Correct 21 ms 476 KB Output is correct
33 Correct 21 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 428 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 23 ms 344 KB Output is correct
15 Correct 22 ms 348 KB Output is correct
16 Correct 21 ms 344 KB Output is correct
17 Correct 20 ms 348 KB Output is correct
18 Correct 16 ms 468 KB Output is correct
19 Correct 19 ms 468 KB Output is correct
20 Correct 17 ms 348 KB Output is correct
21 Correct 13 ms 344 KB Output is correct
22 Correct 18 ms 348 KB Output is correct
23 Correct 6 ms 348 KB Output is correct
24 Correct 13 ms 460 KB Output is correct
25 Correct 13 ms 348 KB Output is correct
26 Correct 16 ms 348 KB Output is correct
27 Correct 17 ms 464 KB Output is correct
28 Correct 18 ms 348 KB Output is correct
29 Correct 17 ms 472 KB Output is correct
30 Correct 16 ms 344 KB Output is correct
31 Correct 20 ms 348 KB Output is correct
32 Correct 21 ms 476 KB Output is correct
33 Correct 21 ms 472 KB Output is correct
34 Execution timed out 2037 ms 348 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 428 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 23 ms 344 KB Output is correct
15 Correct 22 ms 348 KB Output is correct
16 Correct 21 ms 344 KB Output is correct
17 Correct 20 ms 348 KB Output is correct
18 Correct 16 ms 468 KB Output is correct
19 Correct 19 ms 468 KB Output is correct
20 Correct 17 ms 348 KB Output is correct
21 Correct 13 ms 344 KB Output is correct
22 Correct 18 ms 348 KB Output is correct
23 Correct 6 ms 348 KB Output is correct
24 Correct 13 ms 460 KB Output is correct
25 Correct 13 ms 348 KB Output is correct
26 Correct 16 ms 348 KB Output is correct
27 Correct 17 ms 464 KB Output is correct
28 Correct 18 ms 348 KB Output is correct
29 Correct 17 ms 472 KB Output is correct
30 Correct 16 ms 344 KB Output is correct
31 Correct 20 ms 348 KB Output is correct
32 Correct 21 ms 476 KB Output is correct
33 Correct 21 ms 472 KB Output is correct
34 Execution timed out 2037 ms 348 KB Time limit exceeded
35 Halted 0 ms 0 KB -