답안 #946051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946051 2024-03-14T09:52:02 Z efedmrlr Monochrome Points (JOI20_monochrome) C++17
4 / 100
2000 ms 436 KB
// #pragma GCC optimize("O3,Ofast,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>

using namespace std;


#define lli long long int
#define MP make_pair
#define pb push_back
#define REP(i,n) for(int i = 0; (i) < (n); (i)++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()


void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}


const double EPS = 0.00001;
const int INF = 1e9+500;
const int N = 3e5+5;
const int ALPH = 26;
const int LGN = 25;
constexpr int MOD = 1e9+7;
int n,m,q;
vector<int> b, w;
int counter() {
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            int a1= b[i], a2 = b[j], b1 = w[i], b2 = w[j];
            if(a1 > b1) swap(a1, b1);
            if(a2 > b2) swap(a2, b2);
            if((a1 < a2 && a2 < b1) != (a1 < b2 && b2 < b1)) {
                cnt++;
            }
        }
    }
    return cnt;
}
inline void solve() {
    cin>>n;
    string s;
    cin >> s;
    for(int i = 0; i<2*n; i++) {
        auto c = s[i];
        if(c == 'B') b.pb(i);
        else w.pb(i);
    }
    int ans = 0;
    do
    {   
        ans = max(ans, counter());
    } while (next_permutation(all(w)));
    
    cout << ans << "\n";

}
 
signed main() {

    //fastio();
    int test = 1;
    //cin>>test;
    while(test--) {
        solve();
    }
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 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 7 ms 436 KB Output is correct
10 Correct 8 ms 348 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 9 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 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 7 ms 436 KB Output is correct
10 Correct 8 ms 348 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 9 ms 348 KB Output is correct
14 Execution timed out 2067 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 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 7 ms 436 KB Output is correct
10 Correct 8 ms 348 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 9 ms 348 KB Output is correct
14 Execution timed out 2067 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 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 7 ms 436 KB Output is correct
10 Correct 8 ms 348 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 9 ms 348 KB Output is correct
14 Execution timed out 2067 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -