Submission #898624

# Submission time Handle Problem Language Result Execution time Memory
898624 2024-01-04T23:37:11 Z AdamGS Monochrome Points (JOI20_monochrome) C++17
25 / 100
2000 ms 544 KB
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  ll b=0, w=n, p=0;
  rep(i, 2*n) {
    if(s[i]=='B') ++b; else --w;
    if(b==w) {
      p=i;
      break;
    }
  }
  ll ans=0;
  for(int p=-1; p<2*n; ++p) {
    vector<pair<int,int>>V;
    int l=2*n-1;
    bool ok=true;
    for(int i=p; i>=0; --i) if(s[i]=='B') {
      while(l>=0 && s[l]=='B') --l;
      if(i>l) {
        ok=false;
        break;
      }
      V.pb({i, l});
      --l;
    }
    if(!ok) continue;
    l=0;
    for(int i=p+1; i<2*n; ++i) if(s[i]=='B') {
      while(l<2*n && s[l]=='B') ++l;
      if(l>i) {
        ok=false;
        break;
      }
      V.pb({l, i});
      ++l;
    }
    if(!ok) continue;
    ll sum=0;
    rep(i, V.size()) rep(j, i) if((V[i].st<V[j].st && V[j].st<V[i].nd && V[i].nd<V[j].nd) 
        || (V[j].st<V[i].st && V[i].st<V[j].nd && V[j].nd<V[i].nd)) {
      ++sum;
    }
    ans=max(ans, sum);
  }
  cout << ans << '\n';
}

Compilation message

monochrome.cpp: In function 'int main()':
monochrome.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
monochrome.cpp:50:5: note: in expansion of macro 'rep'
   50 |     rep(i, V.size()) rep(j, i) if((V[i].st<V[j].st && V[j].st<V[i].nd && V[i].nd<V[j].nd)
      |     ^~~
monochrome.cpp:15:16: warning: variable 'p' set but not used [-Wunused-but-set-variable]
   15 |   ll b=0, w=n, p=0;
      |                ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 29 ms 456 KB Output is correct
15 Correct 28 ms 348 KB Output is correct
16 Correct 24 ms 344 KB Output is correct
17 Correct 33 ms 348 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 16 ms 344 KB Output is correct
20 Correct 20 ms 344 KB Output is correct
21 Correct 16 ms 348 KB Output is correct
22 Correct 21 ms 464 KB Output is correct
23 Correct 9 ms 344 KB Output is correct
24 Correct 15 ms 344 KB Output is correct
25 Correct 20 ms 456 KB Output is correct
26 Correct 10 ms 468 KB Output is correct
27 Correct 12 ms 348 KB Output is correct
28 Correct 15 ms 464 KB Output is correct
29 Correct 9 ms 348 KB Output is correct
30 Correct 9 ms 348 KB Output is correct
31 Correct 10 ms 348 KB Output is correct
32 Correct 12 ms 348 KB Output is correct
33 Correct 30 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 29 ms 456 KB Output is correct
15 Correct 28 ms 348 KB Output is correct
16 Correct 24 ms 344 KB Output is correct
17 Correct 33 ms 348 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 16 ms 344 KB Output is correct
20 Correct 20 ms 344 KB Output is correct
21 Correct 16 ms 348 KB Output is correct
22 Correct 21 ms 464 KB Output is correct
23 Correct 9 ms 344 KB Output is correct
24 Correct 15 ms 344 KB Output is correct
25 Correct 20 ms 456 KB Output is correct
26 Correct 10 ms 468 KB Output is correct
27 Correct 12 ms 348 KB Output is correct
28 Correct 15 ms 464 KB Output is correct
29 Correct 9 ms 348 KB Output is correct
30 Correct 9 ms 348 KB Output is correct
31 Correct 10 ms 348 KB Output is correct
32 Correct 12 ms 348 KB Output is correct
33 Correct 30 ms 464 KB Output is correct
34 Execution timed out 2060 ms 544 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 29 ms 456 KB Output is correct
15 Correct 28 ms 348 KB Output is correct
16 Correct 24 ms 344 KB Output is correct
17 Correct 33 ms 348 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 16 ms 344 KB Output is correct
20 Correct 20 ms 344 KB Output is correct
21 Correct 16 ms 348 KB Output is correct
22 Correct 21 ms 464 KB Output is correct
23 Correct 9 ms 344 KB Output is correct
24 Correct 15 ms 344 KB Output is correct
25 Correct 20 ms 456 KB Output is correct
26 Correct 10 ms 468 KB Output is correct
27 Correct 12 ms 348 KB Output is correct
28 Correct 15 ms 464 KB Output is correct
29 Correct 9 ms 348 KB Output is correct
30 Correct 9 ms 348 KB Output is correct
31 Correct 10 ms 348 KB Output is correct
32 Correct 12 ms 348 KB Output is correct
33 Correct 30 ms 464 KB Output is correct
34 Execution timed out 2060 ms 544 KB Time limit exceeded
35 Halted 0 ms 0 KB -