結果

問題 No.1943 消えたAGCT(1)
ユーザー erbowlerbowl
提出日時 2022-05-20 21:40:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 990 bytes
コンパイル時間 1,985 ms
コンパイル使用メモリ 202,204 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 12:05:43
合計ジャッジ時間 3,239 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 14 ms
4,348 KB
testcase_10 AC 13 ms
4,348 KB
testcase_11 AC 13 ms
4,348 KB
testcase_12 AC 14 ms
4,348 KB
testcase_13 AC 8 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 16 ms
4,348 KB
testcase_16 AC 13 ms
4,348 KB
testcase_17 AC 14 ms
4,348 KB
testcase_18 AC 18 ms
4,348 KB
testcase_19 AC 17 ms
4,348 KB
testcase_20 AC 18 ms
4,348 KB
testcase_21 AC 18 ms
4,348 KB
testcase_22 AC 17 ms
4,348 KB
testcase_23 AC 17 ms
4,348 KB
testcase_24 AC 14 ms
4,348 KB
testcase_25 AC 14 ms
4,348 KB
testcase_26 AC 14 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
}
0