Submission #898623

# Submission time Handle Problem Language Result Execution time Memory
898623 2024-01-04T23:36:57 Z AdamGS Monochrome Points (JOI20_monochrome) C++17
0 / 100
0 ms 348 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=-1;
  rep(i, 2*n) {
    if(s[i]=='B') ++b; else --w;
    if(b==w) {
      p=i;
      break;
    }
  }
  vector<pair<int,int>>V;
  int l=2*n-1;
  for(int i=p; i>=0; --i) if(s[i]=='B') {
    while(s[l]=='B') --l;
    V.pb({i, l});
    --l;
  }
  l=0;
  for(int i=p+1; i<2*n; ++i) if(s[i]=='B') {
    while(s[l]=='B') ++l;
    V.pb({l, i});
    ++l;
  }
  ll ans=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)) ++ans;
  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:37:3: note: in expansion of macro 'rep'
   37 |   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)) ++ans;
      |   ^~~
# 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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -