# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
813789 | vjudge1 | Monochrome Points (JOI20_monochrome) | C++17 | 2043 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "/home/trucmai/.vim/tools.h"
#define debug(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl;
#else
#define debug(x...)
#endif
void open(){
if(fopen("i.inp","r")){
freopen("i.inp","r",stdin);
freopen("o.out","w",stdout);
}
}
#define ll long long
#define all(a) (a).begin(), (a).end()
#define vi vector<ll>
#define pi pair<ll,ll>
#define pii pair<ll,pair<ll,ll>>
#define fi first
#define se second
#define gcd __gcd
#define mset(a,v) memset(a, v, sizeof(a))
#define endl '\n'
#define spc " "
const int MN = 1e6 + 5,LOG = 27;
const ll MOD = 1e9 + 7,INF = 1e9;
ll n; string s;
vector<ll>b,w;
bool cross(ll x1,ll y1,ll x2,ll y2){
if(x1 > y1) swap(x1, y1);
if(x2 > y2) swap(x2, y2);
if(x1 < x2 && y2 < y1) return false;
if(x2 < x1 && y1 < y2) return false;
if(x1 > y2 || x2 > y1) return false;
return true;
}
void solve(){
cin>>n>>s;
for(ll i = 0;i < 2*n;++i){
if(s[i] == 'B') b.push_back(i);
else w.push_back(i);
}
sort(all(b)); sort(all(w));
//sub 2: best strats: w[i] -> b[i+k]
ll res = 0;
for(ll k = 0;k < n;++k){
ll cnt = 0;
for(ll i = 0;i < n;++i)
for(ll j = i+1;j < n;++j)
if(cross(w[i],b[(i+k)%n],w[j],b[(j+k)%n])) ++cnt;
res = max(res,cnt);
}
cout<<res<<endl;
}
signed main(){
cin.tie(0) -> sync_with_stdio(0);
open();
ll t = 1; //cin>>t;
while(t--) solve();
#ifdef LOCAL
cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |