Submission #495318

# Submission time Handle Problem Language Result Execution time Memory
495318 2021-12-18T11:41:51 Z 600Mihnea Monochrome Points (JOI20_monochrome) C++17
25 / 100
2000 ms 332 KB
#include <iostream>
#include <vector>
#include <string>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;
const int N = 400000 + 7;
int n;
string s;


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

  cin >> n >> s;

  function<ll(vector<int>, vector<int>)> compute = [&](vector<int> a, vector<int> b) {
    ll sol = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (min(a[i], b[i]) < min(a[j], b[j]) && min(a[j], b[j]) < max(a[i], b[i]) && max(a[i], b[i]) < max(a[j], b[j])) {
          sol++;
        }
      }
    }
    return sol;
  };


  function<vector<int>(vector<int>, int)> shift = [&](vector<int> a, int cnt) {
    vector<int> b((int)a.size());
    for (int i = 0; i < (int)a.size(); i++) {
      b[(i + cnt) % (int)a.size()] = a[i];
    }
    return b;
  };

  vector<int> a, b;
  for (int i = 0; i < 2 * n; i++) {
    if (s[i] != s[0]) {
      a.push_back(i);
    }
    else {
      b.push_back(i);
    }
  }

  ll sol = 0;

  for (int cnt = 0; cnt < n; cnt++) {
    sol = max(sol, compute(a, shift(b, cnt)));
  }
  cout << sol << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 42 ms 204 KB Output is correct
15 Correct 38 ms 204 KB Output is correct
16 Correct 40 ms 300 KB Output is correct
17 Correct 43 ms 300 KB Output is correct
18 Correct 29 ms 204 KB Output is correct
19 Correct 34 ms 300 KB Output is correct
20 Correct 31 ms 204 KB Output is correct
21 Correct 26 ms 204 KB Output is correct
22 Correct 28 ms 204 KB Output is correct
23 Correct 11 ms 320 KB Output is correct
24 Correct 36 ms 312 KB Output is correct
25 Correct 24 ms 204 KB Output is correct
26 Correct 31 ms 204 KB Output is correct
27 Correct 43 ms 204 KB Output is correct
28 Correct 38 ms 312 KB Output is correct
29 Correct 30 ms 204 KB Output is correct
30 Correct 26 ms 204 KB Output is correct
31 Correct 42 ms 204 KB Output is correct
32 Correct 43 ms 204 KB Output is correct
33 Correct 42 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 42 ms 204 KB Output is correct
15 Correct 38 ms 204 KB Output is correct
16 Correct 40 ms 300 KB Output is correct
17 Correct 43 ms 300 KB Output is correct
18 Correct 29 ms 204 KB Output is correct
19 Correct 34 ms 300 KB Output is correct
20 Correct 31 ms 204 KB Output is correct
21 Correct 26 ms 204 KB Output is correct
22 Correct 28 ms 204 KB Output is correct
23 Correct 11 ms 320 KB Output is correct
24 Correct 36 ms 312 KB Output is correct
25 Correct 24 ms 204 KB Output is correct
26 Correct 31 ms 204 KB Output is correct
27 Correct 43 ms 204 KB Output is correct
28 Correct 38 ms 312 KB Output is correct
29 Correct 30 ms 204 KB Output is correct
30 Correct 26 ms 204 KB Output is correct
31 Correct 42 ms 204 KB Output is correct
32 Correct 43 ms 204 KB Output is correct
33 Correct 42 ms 204 KB Output is correct
34 Execution timed out 2062 ms 332 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 42 ms 204 KB Output is correct
15 Correct 38 ms 204 KB Output is correct
16 Correct 40 ms 300 KB Output is correct
17 Correct 43 ms 300 KB Output is correct
18 Correct 29 ms 204 KB Output is correct
19 Correct 34 ms 300 KB Output is correct
20 Correct 31 ms 204 KB Output is correct
21 Correct 26 ms 204 KB Output is correct
22 Correct 28 ms 204 KB Output is correct
23 Correct 11 ms 320 KB Output is correct
24 Correct 36 ms 312 KB Output is correct
25 Correct 24 ms 204 KB Output is correct
26 Correct 31 ms 204 KB Output is correct
27 Correct 43 ms 204 KB Output is correct
28 Correct 38 ms 312 KB Output is correct
29 Correct 30 ms 204 KB Output is correct
30 Correct 26 ms 204 KB Output is correct
31 Correct 42 ms 204 KB Output is correct
32 Correct 43 ms 204 KB Output is correct
33 Correct 42 ms 204 KB Output is correct
34 Execution timed out 2062 ms 332 KB Time limit exceeded
35 Halted 0 ms 0 KB -