Submission #427945

#TimeUsernameProblemLanguageResultExecution timeMemory
427945cfalasMonochrome Points (JOI20_monochrome)C++14
0 / 100
1 ms204 KiB
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define INF 10000000 #define MOD 1000000007 #define MID ((l+r)/2) #define HASHMOD 2305843009213693951 #define ll long long #define ull unsigned long long #define F first #define S second typedef pair<ll, ll> ii; typedef pair<ii, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef map<int, int> mii; #define EPS 1e-6 #define FOR(i,n) for(int i=0;i<((int)(n));i++) #define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++) #define FOA(v, a) for(auto v : a) int t, n; vi a, b; int dist(int a, int b){ return min(abs(a-b), abs(a-b+n)); } int main(){ cin>>n; string s; cin>>s; n*=2; set<int> w, b; FOR(i,n){ if(s[i]=='W') w.insert(i); else b.insert(i); } vi c(n); /* FOR(i,n){ if(s[i]=='B'){ int opp = (i+n/2)%n; auto l1_it = w.lower_bound(opp); if(l1_it==w.end()) l1_it = w.begin(); int d1 = *l1_it; auto l2_it = (w.upper_bound(opp)); if(l2_it==w.begin()) l2_it = w.end(); int d2 = *(--l2_it); int ans=d2; if(dist(d1,opp) > dist(opp,d2)){ ans = d2; } else{ ans = d1; } cout<<i<<" "<<d1<<" "<<d2<<" "<<ans<<endl; w.erase(ans); assert(ans!=i); c[i] = ans; c[ans] = i; } }*/ int bans=0; FORi(off,n/4-2, n/4+3){ auto it = b.begin(); FOR(i,off) it++; FOA(v,w){ c[v] = *it; c[*it] = v; //cout<<v<<" "<<*it<<endl; it++; if(it==b.end()) it = b.begin(); } int ans=0; FOR(i,n){ if(s[i]=='B') FORi(j,min(i,c[i])+1, max(i,c[i])){ if(c[j]>max(i,c[i]) || c[j]<min(i,c[i])) ans++; } } bans = max(bans, ans); } cout<<bans/2<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...