結果
| 問題 |
No.2073 Concon Substrings (Swap Version)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-13 21:18:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 2,000 ms |
| コード長 | 1,924 bytes |
| コンパイル時間 | 937 ms |
| コンパイル使用メモリ | 117,292 KB |
| 最終ジャッジ日時 | 2025-02-15 10:15:53 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 37 |
ソースコード
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include <unordered_set>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;
int main(){
int N;
cin>>N;
string S;
cin>>S;
vector<map<char,int>> mp(3);
for(int i=0;i<3*N;i++){
mp[i%3][S[i]]++;
}
int cnt=0;
vector<int> ans(3);
for(int i=0;i<3;i++){
//min({mp[0]['c'],mp[1]['o'],mp[2]['n']})
//ans=max(ans,min({mp[i]['c'],mp[(i+1)%3]['o'],mp[(i+2)%3]['n']}));
ans[i]=min({mp[i]['c'],mp[(i+1)%3]['o'],mp[(i+2)%3]['n']});
cnt+=ans[i];
}
if(cnt==N){
if(ans[0]==N){
cout<<N<<endl;
}else{
cout<<N-1<<endl;
}
return 0;
}else{
cout<<cnt<<endl;
}
return 0;
/*
ans+=min({mp[0]['c'],mp[1]['o'],mp[2]['n']});
{
if(S[0]=='o'){
mp[0]['o']--;
}
if(S[1]=='n'){
mp[1]['n']--;
}
if(S[3*N-1]=='c'){
mp[2]['c']--;
}
ans+=min({mp[2]['c'],mp[0]['o'],mp[1]['n']});
if(S[0]=='o'){
mp[0]['o']++;
}
if(S[1]=='n'){
mp[1]['n']++;
}
if(S[3*N-1]=='c'){
mp[2]['c']++;
}
}
{
if(S[0]=='n'){
mp[0]['n']--;
}
if(S[3*N-2]=='c'){
mp[1]['c']--;
}
if(S[3*N-1]=='o'){
mp[2]['o']--;
}
ans+=min({mp[1]['c'],mp[2]['o'],mp[0]['n']});
if(S[0]=='n'){
mp[0]['n']++;
}
if(S[3*N-2]=='c'){
mp[1]['c']++;
}
if(S[3*N-1]=='o'){
mp[2]['o']++;
}
}
*/
}