結果

問題 No.1943 消えたAGCT(1)
ユーザー nawawannawawan
提出日時 2022-05-20 22:02:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,498 bytes
コンパイル時間 1,134 ms
コンパイル使用メモリ 89,624 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 12:41:37
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 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 14 ms
4,348 KB
testcase_11 AC 14 ms
4,348 KB
testcase_12 AC 15 ms
4,348 KB
testcase_13 AC 9 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 19 ms
4,348 KB
testcase_16 AC 16 ms
4,348 KB
testcase_17 AC 17 ms
4,348 KB
testcase_18 AC 21 ms
4,348 KB
testcase_19 AC 21 ms
4,348 KB
testcase_20 AC 21 ms
4,348 KB
testcase_21 AC 21 ms
4,348 KB
testcase_22 AC 23 ms
4,348 KB
testcase_23 AC 23 ms
4,348 KB
testcase_24 AC 15 ms
4,348 KB
testcase_25 AC 15 ms
4,348 KB
testcase_26 AC 15 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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