結果
問題 |
No.2073 Concon Substrings (Swap Version)
|
ユーザー |
|
提出日時 | 2023-07-13 21:12:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,861 bytes |
コンパイル時間 | 999 ms |
コンパイル使用メモリ | 114,616 KB |
最終ジャッジ日時 | 2025-02-15 10:15:45 |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 17 WA * 20 |
ソースコード
#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 ans=0; 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+=min({mp[i]['c'],mp[(i+1)%3]['o'],mp[(i+2)%3]['n']}); } if(min({mp[0]['c'],mp[(0+1)%3]['o'],mp[(0+2)%3]['n']})==N){ cout<<N<<endl; return 0; }else{ cout<<ans<<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']++; } } */ cout<<ans<<endl; }