結果
| 問題 |
No.2073 Concon Substrings (Swap Version)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-16 21:56:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 920 bytes |
| コンパイル時間 | 2,112 ms |
| コンパイル使用メモリ | 172,988 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-21 19:46:29 |
| 合計ジャッジ時間 | 3,602 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 17 WA * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
string sub = "con";
vector<string> s(3);
{
string xd; cin >> xd;
for (int i = 0; i < 3 * n; i++) {
s[i % 3].push_back(xd[i]);
}
}
int ans = 0;
for (int i = 0; i < 3; i++) {
int cnt = n;
for (int j = 0; j < 3; j++) {
cnt = min(cnt, (int)count_if(s[(i + j) % 3].begin(), s[(i + j) % 3].end(), [&](char u) {
return u == sub[j];
}));
sort(s[(i + j) % 3].begin(), s[(i + j) % 3].end(), [&](char u, char v) {
return (u == sub[j]) < (v == sub[j]);
});
}
ans += cnt;
while (cnt--) {
for (int j = 0; j < 3; j++) {
s[j].pop_back();
}
}
}
cout << ans;
}