Submission #292892

#TimeUsernameProblemLanguageResultExecution timeMemory
292892limabeansMonochrome Points (JOI20_monochrome)C++17
4 / 100
2073 ms384 KiB
#include <bits/stdc++.h> using namespace std; template<typename T> void out(T x) { cout << x << endl; exit(0); } #define watch(x) cout << (#x) << " is " << (x) << endl using ll = long long; const ll mod = 1e9+7; const int maxn = 1e6 + 5; int n; string s; bool used[maxn]; vector<pair<int,int>> v; int best=0; bool isect(pair<int,int> p, pair<int,int> q) { if (max(p.first,q.first) >= min(p.second,q.second)) return false; if (p.first>q.first) swap(p,q); if (p.first<=q.first && q.second<=p.second) return false; return true; } void eval() { assert(int(v.size())==n/2); for (auto &p: v) { if (p.first>p.second) { swap(p.first,p.second); } } int res = 0; for (int i=0; i<n/2; i++) { for (int j=i+1; j<n/2; j++) { if (isect(v[i],v[j])) res++; } } // watch(res); // for (auto p: v) { // cout<<p.first<<" "<<p.second<<endl; // } best = max(best, res); } void dfs(int i) { if (i == n) { eval(); } else { if (s[i]=='B') { for (int j=0; j<n; j++) { if (s[j]=='W') { if (!used[j]) { used[j]=true; v.push_back({i,j}); dfs(i+1); v.pop_back(); used[j]=false; } } } } else { dfs(i+1); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>s; n *= 2; dfs(0); cout<<best<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...