Submission #1214246

#TimeUsernameProblemLanguageResultExecution timeMemory
1214246mychecksedadMonochrome Points (JOI20_monochrome)C++20
25 / 100
2094 ms328 KiB
/* Author : Mychecksdead  */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;


int n;
string s;
void solve(){
  cin >> n >> s;
  n *= 2;
  int anss = 0;
  for(int p = 0; p < n/2; ++p){
    vector<pii> a;
    vector<bool> vis(2*n);
    for(int i = p; i < n/2 + p; ++i){
      for(int j = n/2 + p; j < n + p; ++j){
        if(!vis[j % n] && s[i] != s[j % n]){
          vis[j%n] = 1;
          if(i < j%n)
          a.pb({i, j%n});
        else a.pb({j%n, i});
          break;
        }
      }
    }
    sort(all(a));
    int ans = 0;
    for(int i = 0; i < n/2; ++i){
      // cerr << a[i].ff << ' ' << a[i].ss << '\n';
      for(int j=i+1; j < n/2; ++j){
        if(a[i].ss >= a[j].ff && a[i].ss <= a[j].ss) ++ans;
      }
    }
    cerr << ans << '\n';
    anss = max(anss, ans);
  }
  cout << anss;
}


int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tt = 1, aa;
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  while(tt--){
    solve();
    en;
  }
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
  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...