結果
問題 | No.1943 消えたAGCT(1) |
ユーザー | Kichico |
提出日時 | 2022-05-24 12:00:52 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 169 ms / 2,000 ms |
コード長 | 3,189 bytes |
コンパイル時間 | 2,228 ms |
コンパイル使用メモリ | 216,224 KB |
実行使用メモリ | 27,228 KB |
最終ジャッジ日時 | 2024-09-20 13:35:20 |
合計ジャッジ時間 | 5,445 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 153 ms
27,096 KB |
testcase_10 | AC | 4 ms
5,376 KB |
testcase_11 | AC | 148 ms
27,220 KB |
testcase_12 | AC | 156 ms
27,228 KB |
testcase_13 | AC | 90 ms
17,748 KB |
testcase_14 | AC | 5 ms
5,376 KB |
testcase_15 | AC | 159 ms
25,692 KB |
testcase_16 | AC | 126 ms
21,336 KB |
testcase_17 | AC | 134 ms
22,356 KB |
testcase_18 | AC | 165 ms
27,220 KB |
testcase_19 | AC | 165 ms
27,228 KB |
testcase_20 | AC | 167 ms
27,224 KB |
testcase_21 | AC | 169 ms
27,224 KB |
testcase_22 | AC | 165 ms
27,224 KB |
testcase_23 | AC | 165 ms
27,224 KB |
testcase_24 | AC | 146 ms
27,224 KB |
testcase_25 | AC | 144 ms
27,100 KB |
testcase_26 | AC | 5 ms
5,376 KB |
ソースコード
#include "bits/stdc++.h" using namespace std; using ll = int64_t; using ld = long double; using ull = unsigned long long; #define ALL(x) x.begin(),x.end() #define rep(iter,from,to) for(ll iter=from;iter<to;++iter) #define fore(variable,container) for(auto& variable:container) #define forc(variable,container) for(auto& variable:container) cout<<variable<<endl; const ll MOD = 998244353; const ll INF = 1e17; const vector<ll> dx{ 1,0,1 }, dy{ 0,1,1 }; //####################################################################### void op(vector<ll> vec) { ll size = (ll)vec.size(); for (ll i = 0; i < size - 1; ++i) cout << vec[i] << " "; cout << vec.back() << endl; } void op(vector<vector<ll>> vec) { ll height = (ll)vec.size(); ll width = (ll)vec[0].size(); for (ll i = 0; i < height; ++i) { for (ll j = 0; j < width - 1; ++j) cout << vec[i][j] << " "; cout << vec[i].back() << endl; } } void twoText(bool identifier, string outTrue, string outFalse) { if (identifier) cout << outTrue << endl; else cout << outFalse << endl; } void twoText(bool identifier) { if (identifier) cout << "Yes" << endl; else cout << "No" << endl; } template <class T> T vecsum(vector<T>& vec) { return accumulate(ALL(vec), (T)0); } template<class T, ll> T vecsum(vector<T>& vec, ll K) { ll ret = 0; rep(i, 0, K) ret += vec[i]; return ret; } template <class T> struct grid { vector<vector<T>> field; grid(ll height, ll width) { field = vector<vector<T>>(height, vector<T>(width, (T)0)); } void input() { rep(i, 0, field.size()) rep(j, 0, field[i].size()) cin >> field[i][j]; } }; //######################################################################### vector<pair<ll, ll>> prime_factorize(ll Num) { ll lim = sqrt(Num) + 1; vector<pair<ll, ll>> pr; //pair<primenumber(素数),Exponentiation(べき数)> vector<bool> listprime(lim); for (ll i = 0; i < lim; ++i) listprime[i] = true; ll root = sqrt(Num); ll res = Num; for (ll i = 2; i <= root; ++i) { ll expnum = 0; if (listprime[i]) { while (res % i == 0) { res /= i; expnum++; } for (ll j = i * 2; j <= root; j += i) listprime[j] = false; } if (expnum != 0) pr.emplace_back(make_pair(i, expnum)); } if (res != 1) pr.emplace_back(make_pair(res, 1)); return pr; } void solve() { ll N; string s; cin >> N >> s; ll cnt = 0; fore(c, s) { if (c == 'A' || c == 'G' || c == 'C' || c == 'T') cnt++; } if (cnt == 0) { cout << 0 << endl; return; } set<ll> pos; rep(i, 1, N + 1) pos.emplace(i); auto it = pos.lower_bound(cnt); ll ans = 0; while (cnt > 0) { auto c = s[*it - 1]; auto next = it; if (c == 'A' || c == 'G' || c == 'C' || c == 'T') { cnt--; next--; } else next++; pos.erase(it); it = next; ans++; } cout << ans << endl; } int main(void) { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); solve(); }