結果
| 問題 |
No.2073 Concon Substrings (Swap Version)
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2022-09-16 21:40:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 2,000 ms |
| コード長 | 681 bytes |
| コンパイル時間 | 1,808 ms |
| コンパイル使用メモリ | 172,924 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-21 18:43:27 |
| 合計ジャッジ時間 | 3,571 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 37 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
int main(){
int N;
cin >> N;
string S;
cin >> S;
string T = "con";
vector<vector<int>> cnt(3, vector<int>(3, 0));
for (int i = 0; i < N * 3; i++){
for (int j = 0; j < 3; j++){
if (S[i] == T[j]){
int x = (i - j + 3) % 3;
cnt[x][j]++;
}
}
}
vector<int> cnt2(3, INF);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
cnt2[i] = min(cnt2[i], cnt[i][j]);
}
}
int sum = cnt2[0] + cnt2[1] + cnt2[2];
if (sum < N){
cout << sum << endl;
} else if (cnt2[0] == N){
cout << N << endl;
} else {
cout << N - 1 << endl;
}
}
SSRS