結果
| 問題 |
No.1943 消えたAGCT(1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-20 22:02:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 1,498 bytes |
| コンパイル時間 | 1,001 ms |
| コンパイル使用メモリ | 90,640 KB |
| 最終ジャッジ日時 | 2025-01-29 10:38:24 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
using namespace std;
int main()
{
int N;
cin >> N;
string S;
cin >> S;
int cnt = 0;
set<char> s;
s.insert('A');
s.insert('C');
s.insert('G');
s.insert('T');
for (int i = 0; i < N; i++)
{
if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
cnt++;
}
int ans = 0;
int ind = cnt - 2;
int rest = cnt;
while (rest > 0)
{
bool f = false;
for (int i = cnt - 1; i < N; i++)
{
f = true;
ans++;
if (s.count(S[i]))
{
cnt = i + 2;
rest--;
while (ind >= 0)
{
if (s.count(S[ind]))
{
ans++;
rest--;
ind--;
}
else
{
ans++;
ind--;
break;
}
}
break;
}
}
if (!f)
{
while (ind >= 0 && rest > 0)
{
if (s.count(S[ind]))
{
rest--;
}
ind--;
ans++;
}
}
}
cout << ans << endl;
}