結果

問題 No.1943 消えたAGCT(1)
ユーザー nawawannawawan
提出日時 2022-05-20 21:59:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,246 bytes
コンパイル時間 865 ms
コンパイル使用メモリ 89,916 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-20 12:38:04
合計ジャッジ時間 4,887 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 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 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

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 && s.count(S[ind]))
                {
                    ans++;
                    rest--;
                    ind--;
                }
                break;
            }
        }
        if (!f)
        {
            while (ind >= 0)
            {
                if (s.count(S[ind]))
                {
                    rest--;
                }
                ind--;
                ans++;
            }
        }
    }
    cout << ans << endl;
}
0