結果
問題 |
No.1943 消えたAGCT(1)
|
ユーザー |
![]() |
提出日時 | 2023-05-12 19:08:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 73 ms / 2,000 ms |
コード長 | 606 bytes |
コンパイル時間 | 877 ms |
コンパイル使用メモリ | 76,036 KB |
実行使用メモリ | 19,500 KB |
最終ジャッジ日時 | 2024-11-28 15:34:59 |
合計ジャッジ時間 | 3,086 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#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; }