結果
問題 |
No.2073 Concon Substrings (Swap Version)
|
ユーザー |
|
提出日時 | 2022-12-13 00:03:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 729 bytes |
コンパイル時間 | 472 ms |
コンパイル使用メモリ | 68,220 KB |
最終ジャッジ日時 | 2025-02-09 10:40:03 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 21 WA * 16 |
ソースコード
#include <iostream> using namespace std; int d[3][3]; int main() { int n; string s; cin >> n >> s; for (int i = 0; i < n * 3; i++) { if (s[i] == 'c') { d[i % 3][0]++; } if (s[i] == 'o') { d[i % 3][1]++; } if (s[i] == 'n') { d[i % 3][2]++; } } int e[3] = {n, n, n}; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { e[i] = min(e[i], d[(i + j) % 3][j]); } } int ans = e[0] + e[1] + e[2]; if (ans == n) { if (e[0] < n && e[1] < n && e[2] == n) { ans--; } } cout << ans << endl; }