結果

問題 No.1943 消えたAGCT(1)
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-05-12 19:08:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 75,868 KB
実行使用メモリ 19,228 KB
最終ジャッジ日時 2023-08-19 02:37:54
合計ジャッジ時間 3,858 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 53 ms
19,164 KB
testcase_10 AC 42 ms
19,080 KB
testcase_11 AC 42 ms
19,148 KB
testcase_12 AC 48 ms
19,220 KB
testcase_13 AC 28 ms
12,828 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 58 ms
18,072 KB
testcase_16 AC 47 ms
15,352 KB
testcase_17 AC 48 ms
15,992 KB
testcase_18 AC 62 ms
19,104 KB
testcase_19 AC 61 ms
19,164 KB
testcase_20 AC 59 ms
19,100 KB
testcase_21 AC 59 ms
19,092 KB
testcase_22 AC 69 ms
19,160 KB
testcase_23 AC 68 ms
19,216 KB
testcase_24 AC 46 ms
19,228 KB
testcase_25 AC 46 ms
19,148 KB
testcase_26 AC 47 ms
19,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <list>
#include <string>
#include <set>
using namespace std;

int main() {
	list<char> ls;
	int n;
	string str,str2="AGCT";
	cin>>n;
	cin>>str;
	set<char> ss;
	for(int i=0;i<4;i++)ss.insert(str2[i]);
	int c=0;
	for(int i=0;i<n;i++){
		ls.push_back(str[i]);
		if(ss.find(str[i])!=ss.end()){
			c+=1;
		}
	}
	list<char>::iterator it=ls.begin();
	int ans=0;
	for(int i=0;i<c-1;i++)it++;
	while(c>0){
		ans++;
		if(ss.find((*it))!=ss.end()){
			it=ls.erase(it);
			c-=1;
			if(c<1 || it==ls.begin())break;
			it--;
		}else{
			it=ls.erase(it);
		}
	}
	cout<<ans<<endl;
	return 0;
}
0