結果
問題 | No.2073 Concon Substrings (Swap Version) |
ユーザー |
|
提出日時 | 2022-10-22 04:29:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 718 bytes |
コンパイル時間 | 1,904 ms |
コンパイル使用メモリ | 193,604 KB |
最終ジャッジ日時 | 2025-02-08 10:57:33 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using ld = long double; int main(){ cin.tie(0); ios::sync_with_stdio(0); struct con { int c=0, o=0, n=0; }; int N; string S; cin >> N >> S; con x[3]; rep(i,N)rep(j,3) { if(S[i * 3 + j] == 'c') x[j].c++; if(S[i * 3 + j] == 'o') x[j].o++; if(S[i * 3 + j] == 'n') x[j].n++; } int ans = 0; ans += min({x[0].c, x[1].o, x[2].n}); ans += min({x[1].c, x[2].o, x[0].n}); ans += min({x[2].c, x[0].o, x[1].n}); if(ans == N) { if(min({x[0].c, x[1].o, x[2].n}) != N) { ans--; } } cout << ans << endl; }