Submission #536359

#TimeUsernameProblemLanguageResultExecution timeMemory
536359MonarchuwuMonochrome Points (JOI20_monochrome)C++17
4 / 100
5 ms340 KiB
#include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<numeric> #define all(x) x.begin(), x.end() using namespace std; typedef long long ll; const int N = 25 + 8, inf = 0x80808080; int n, n2; char s[N << 1]; vector<int> B, W; bool inside(int l, int r, int p) { return (p - l) * (ll)(p - r) < 0; } int p[N]; int calc() { // B[i], W[p[i]] int ans(0); for (int i = 0; i < n; ++i) for (int j = 0; j < i; ++j) ans += inside(B[i], W[p[i]], B[j]) ^ inside(B[i], W[p[i]], W[p[j]]); return ans; } int main() { cin.tie(NULL)->sync_with_stdio(false); cin >> n >> (s + 1); n2 = n << 1; for (int i = 1; i <= n2; ++i) { if (s[i] == 'B') B.push_back(i); else W.push_back(i); } iota(p, p + n, 0); int ans(0); do { ans = max(ans, calc()); } while (next_permutation(p, p + n)); cout << ans << '\n'; } /** /\_/\ * (= ._.) * / >0 \>1 **/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...