結果
| 問題 |
No.2073 Concon Substrings (Swap Version)
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2022-09-16 21:33:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 713 bytes |
| コンパイル時間 | 1,821 ms |
| コンパイル使用メモリ | 172,956 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-21 18:29:23 |
| 合計ジャッジ時間 | 3,643 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 29 WA * 8 |
ソースコード
#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 || cnt2[1] == N || cnt2[2] == N){
cout << N << endl;
} else {
cout << N - 1 << endl;
}
}
SSRS