結果
| 問題 |
No.1943 消えたAGCT(1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-20 21:40:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 2,000 ms |
| コード長 | 990 bytes |
| コンパイル時間 | 1,895 ms |
| コンパイル使用メモリ | 193,008 KB |
| 最終ジャッジ日時 | 2025-01-29 10:19:52 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
typedef int ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
// #define int long long
signed main(){
ll n;
std::cin >> n;
string s;
std::cin >> s;
ll cnt = 0;
for (auto e : s) {
if(e=='A'||e=='G'||e=='C'||e=='T'){
cnt++;
}
}
ll ans= 0;
if(cnt==0){
std::cout << 0 << std::endl;
return 0;
}
ll l,r;
ll cur = cnt;
l = r = cur-1;
bool isr = true;
while(cnt>0){
ans++;
// std::cout << l<<" "<<r<<" "<<cnt << std::endl;
if(l==r){
cur = r;
}else if(isr){
cur = r;
r++;
}else{
cur = l;
l--;
}
if(s[cur]=='A'||s[cur]=='G'||s[cur]=='C'||s[cur]=='T'){
isr = false;
cnt--;
}else{
isr = true;
}
if(l==r){
l--;
r++;
}
}
std::cout << ans << std::endl;
}