結果
問題 | No.1951 消えたAGCT(2) |
ユーザー | 👑 kmjp |
提出日時 | 2022-05-20 23:41:17 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 354 ms / 3,000 ms |
コード長 | 1,675 bytes |
コンパイル時間 | 2,090 ms |
コンパイル使用メモリ | 203,652 KB |
実行使用メモリ | 223,788 KB |
最終ジャッジ日時 | 2023-10-20 14:37:37 |
合計ジャッジ時間 | 7,365 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
38,484 KB |
testcase_01 | AC | 12 ms
63,060 KB |
testcase_02 | AC | 13 ms
69,204 KB |
testcase_03 | AC | 4 ms
13,856 KB |
testcase_04 | AC | 3 ms
13,856 KB |
testcase_05 | AC | 18 ms
84,260 KB |
testcase_06 | AC | 18 ms
84,260 KB |
testcase_07 | AC | 8 ms
32,340 KB |
testcase_08 | AC | 58 ms
43,392 KB |
testcase_09 | AC | 47 ms
18,852 KB |
testcase_10 | AC | 47 ms
24,984 KB |
testcase_11 | AC | 47 ms
24,996 KB |
testcase_12 | AC | 40 ms
57,692 KB |
testcase_13 | AC | 26 ms
85,676 KB |
testcase_14 | AC | 313 ms
150,336 KB |
testcase_15 | AC | 307 ms
135,904 KB |
testcase_16 | AC | 281 ms
198,252 KB |
testcase_17 | AC | 352 ms
206,840 KB |
testcase_18 | AC | 354 ms
223,788 KB |
testcase_19 | AC | 354 ms
223,788 KB |
testcase_20 | AC | 353 ms
223,788 KB |
testcase_21 | AC | 63 ms
59,752 KB |
testcase_22 | AC | 65 ms
59,948 KB |
testcase_23 | AC | 118 ms
203,160 KB |
testcase_24 | AC | 111 ms
203,160 KB |
testcase_25 | AC | 108 ms
190,896 KB |
testcase_26 | AC | 346 ms
223,788 KB |
testcase_27 | AC | 350 ms
223,788 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;} template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N; string S; template<class V, int ME> class BIT { public: V bit[1<<ME],val[1<<ME]; V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;} void add(int e,V v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;} void set(int e,V v) { add(e,v-val[e]);} int lower_bound(V val) { V tv=0; int i,ent=0; for(i=ME-1;i>=0;i--) if(tv+bit[ent+(1<<i)-1]<val) tv+=bit[ent+(1<<i)-1],ent+=(1<<i); return ent; } }; BIT<int,20> C[26],sum; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>S; FOR(i,N) { S[i]-='A'; sum.add(i,1); C[S[i]].add(i,1); } int ret=0; int rot=0; while(1) { x=C[(26-rot)%26](N)+C[(26-rot+2)%26](N)+C[(26-rot+'G'-'A')%26](N)+C[(26-rot+'T'-'A')%26](N); if(x==0) break; ret++; y=sum.lower_bound(x); sum.add(y,-1); C[S[y]].add(y,-1); rot+=C[S[y]](N); rot%=26; } cout<<ret<<endl; } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }