답안 #293886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
293886 2020-09-08T13:29:58 Z BThero Monochrome Points (JOI20_monochrome) C++17
35 / 100
1099 ms 512 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 = 300 + 5;
const int INF = (int)1e9;

char s[2 * MAXN];
int n, ans;

void solve() {
  scanf("%d", &n);
  scanf("%s", s);
  
  for (int i = 0; i < 2 * n; ++i) {
    vector<char> vec;
  
    for (int j = 0; j < n; ++j) {
      vec.pb(s[j]);
    }
    
    int cur = 0;
    
    for (int j = n; j < 2 * n; ++j) {
      auto it = find(all(vec), ('B' ^ 'W' ^ s[j]));
      cur += (vec.end() - it - 1);
      vec.erase(it);
    }
  
    ans = max(ans, cur);
    rotate(s, s + 1, s + 2 * n);
  }
  
  printf("%d\n", ans);
}

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

  return 0;
}

Compilation message

monochrome.cpp: In function 'void solve()':
monochrome.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
monochrome.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |   scanf("%s", s);
      |   ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 7 ms 256 KB Output is correct
15 Correct 6 ms 256 KB Output is correct
16 Correct 7 ms 288 KB Output is correct
17 Correct 8 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 6 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 4 ms 256 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 4 ms 256 KB Output is correct
25 Correct 3 ms 256 KB Output is correct
26 Correct 4 ms 256 KB Output is correct
27 Correct 4 ms 256 KB Output is correct
28 Correct 7 ms 256 KB Output is correct
29 Correct 4 ms 256 KB Output is correct
30 Correct 6 ms 256 KB Output is correct
31 Correct 5 ms 256 KB Output is correct
32 Correct 4 ms 256 KB Output is correct
33 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 7 ms 256 KB Output is correct
15 Correct 6 ms 256 KB Output is correct
16 Correct 7 ms 288 KB Output is correct
17 Correct 8 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 6 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 4 ms 256 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 4 ms 256 KB Output is correct
25 Correct 3 ms 256 KB Output is correct
26 Correct 4 ms 256 KB Output is correct
27 Correct 4 ms 256 KB Output is correct
28 Correct 7 ms 256 KB Output is correct
29 Correct 4 ms 256 KB Output is correct
30 Correct 6 ms 256 KB Output is correct
31 Correct 5 ms 256 KB Output is correct
32 Correct 4 ms 256 KB Output is correct
33 Correct 5 ms 256 KB Output is correct
34 Correct 540 ms 372 KB Output is correct
35 Correct 555 ms 364 KB Output is correct
36 Correct 606 ms 364 KB Output is correct
37 Correct 498 ms 364 KB Output is correct
38 Correct 381 ms 256 KB Output is correct
39 Correct 703 ms 376 KB Output is correct
40 Correct 381 ms 364 KB Output is correct
41 Correct 403 ms 256 KB Output is correct
42 Correct 578 ms 364 KB Output is correct
43 Correct 881 ms 368 KB Output is correct
44 Correct 465 ms 372 KB Output is correct
45 Correct 488 ms 368 KB Output is correct
46 Correct 485 ms 364 KB Output is correct
47 Correct 442 ms 360 KB Output is correct
48 Correct 999 ms 364 KB Output is correct
49 Correct 1099 ms 368 KB Output is correct
50 Correct 443 ms 480 KB Output is correct
51 Correct 434 ms 256 KB Output is correct
52 Correct 442 ms 480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 7 ms 256 KB Output is correct
15 Correct 6 ms 256 KB Output is correct
16 Correct 7 ms 288 KB Output is correct
17 Correct 8 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 6 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 4 ms 256 KB Output is correct
22 Correct 4 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 4 ms 256 KB Output is correct
25 Correct 3 ms 256 KB Output is correct
26 Correct 4 ms 256 KB Output is correct
27 Correct 4 ms 256 KB Output is correct
28 Correct 7 ms 256 KB Output is correct
29 Correct 4 ms 256 KB Output is correct
30 Correct 6 ms 256 KB Output is correct
31 Correct 5 ms 256 KB Output is correct
32 Correct 4 ms 256 KB Output is correct
33 Correct 5 ms 256 KB Output is correct
34 Correct 540 ms 372 KB Output is correct
35 Correct 555 ms 364 KB Output is correct
36 Correct 606 ms 364 KB Output is correct
37 Correct 498 ms 364 KB Output is correct
38 Correct 381 ms 256 KB Output is correct
39 Correct 703 ms 376 KB Output is correct
40 Correct 381 ms 364 KB Output is correct
41 Correct 403 ms 256 KB Output is correct
42 Correct 578 ms 364 KB Output is correct
43 Correct 881 ms 368 KB Output is correct
44 Correct 465 ms 372 KB Output is correct
45 Correct 488 ms 368 KB Output is correct
46 Correct 485 ms 364 KB Output is correct
47 Correct 442 ms 360 KB Output is correct
48 Correct 999 ms 364 KB Output is correct
49 Correct 1099 ms 368 KB Output is correct
50 Correct 443 ms 480 KB Output is correct
51 Correct 434 ms 256 KB Output is correct
52 Correct 442 ms 480 KB Output is correct
53 Runtime error 1 ms 512 KB Execution killed with signal 11
54 Halted 0 ms 0 KB -