結果
| 問題 |
No.1943 消えたAGCT(1)
|
| コンテスト | |
| ユーザー |
naskya
|
| 提出日時 | 2022-04-13 21:40:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 2,000 ms |
| コード長 | 768 bytes |
| コンパイル時間 | 662 ms |
| コンパイル使用メモリ | 75,024 KB |
| 最終ジャッジ日時 | 2025-01-28 17:37:10 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <algorithm>
#include <iostream>
#include <iterator>
#include <list>
int main() {
int n;
std::cin >> n;
std::list<char> s;
std::copy_n(std::istream_iterator<char>(std::cin), n, std::back_inserter(s));
const auto is_AGCT = [](const char c) {
return c == 'A' || c == 'G' || c == 'C' || c == 'T';
};
auto to_remove = std::count_if(s.cbegin(), s.cend(), is_AGCT);
if (to_remove == 0) {
std::cout << "0\n";
return 0;
}
auto iter = std::next(s.begin(), to_remove - 1);
int res = 0;
while (true) {
bool f = is_AGCT(*iter);
iter = s.erase(iter);
++res;
if (f) {
if (to_remove == 1) {
break;
} else {
--to_remove;
--iter;
}
}
}
std::cout << res << '\n';
}
naskya