Submission #293818

# Submission time Handle Problem Language Result Execution time Memory
293818 2020-09-08T12:38:18 Z BThero Monochrome Points (JOI20_monochrome) C++17
4 / 100
2000 ms 384 KB
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 600 + 5;

char s[MAXN];
int n;

void solve() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  vector<int> A, B;
  
  for (int i = 1; i <= 2 * n; ++i) {
    if (s[i] == 'B') {
      A.pb(i);
    }
    else {
      B.pb(i);
    }
  }
  
  int ans = 0;
  
  do {
    int cur = 0;
  
    for (int i = 0; i < n; ++i) {
      int lc = A[i], rc = B[i];
      
      if (lc > rc) {
        swap(lc, rc);
      }
      
      for (int j = i + 1; j < n; ++j) {
        int ln = A[j], rn = B[j];
        
        if (ln > rn) {
          swap(ln, rn);
        }
        
        if (ln < lc && lc < rn && rn < rc) {
          ++cur;
        }
        else if (lc < ln && ln < rc && rc < rn) {
          ++cur;
        }
      }
    }
    
    ans = max(ans, cur);
  }
  while (next_permutation(all(B)));
  
  printf("%d\n", ans);
}

int main() {
  int tt = 1;
  
  while (tt--) {
    solve();
  }

  return 0;
}

Compilation message

monochrome.cpp: In function 'void solve()':
monochrome.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
monochrome.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |   scanf("%s", s + 1);
      |   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 8 ms 256 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 10 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 8 ms 256 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 10 ms 256 KB Output is correct
14 Execution timed out 2025 ms 256 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 8 ms 256 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 10 ms 256 KB Output is correct
14 Execution timed out 2025 ms 256 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 8 ms 256 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 10 ms 256 KB Output is correct
14 Execution timed out 2025 ms 256 KB Time limit exceeded
15 Halted 0 ms 0 KB -