結果

問題 No.1654 Binary Compression
ユーザー 👑 kmjpkmjp
提出日時 2021-08-21 00:26:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 1,643 bytes
コンパイル時間 2,733 ms
コンパイル使用メモリ 202,676 KB
実行使用メモリ 41,580 KB
最終ジャッジ日時 2024-04-22 09:49:16
合計ジャッジ時間 7,974 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 124 ms
39,920 KB
testcase_11 AC 124 ms
40,208 KB
testcase_12 AC 129 ms
41,456 KB
testcase_13 AC 128 ms
41,064 KB
testcase_14 AC 125 ms
40,428 KB
testcase_15 AC 127 ms
40,944 KB
testcase_16 AC 91 ms
41,452 KB
testcase_17 AC 90 ms
41,580 KB
testcase_18 AC 128 ms
41,452 KB
testcase_19 AC 129 ms
41,580 KB
testcase_20 AC 129 ms
41,576 KB
testcase_21 AC 129 ms
41,456 KB
testcase_22 AC 128 ms
41,324 KB
testcase_23 AC 25 ms
22,764 KB
testcase_24 AC 24 ms
23,020 KB
testcase_25 AC 25 ms
22,888 KB
testcase_26 AC 25 ms
22,768 KB
testcase_27 AC 81 ms
37,996 KB
testcase_28 AC 84 ms
38,128 KB
testcase_29 AC 24 ms
22,896 KB
testcase_30 AC 24 ms
22,892 KB
testcase_31 AC 24 ms
22,636 KB
testcase_32 AC 24 ms
23,024 KB
testcase_33 AC 66 ms
37,868 KB
testcase_34 AC 67 ms
38,128 KB
testcase_35 AC 24 ms
24,552 KB
testcase_36 AC 24 ms
24,808 KB
testcase_37 AC 24 ms
24,980 KB
testcase_38 AC 25 ms
24,816 KB
testcase_39 AC 150 ms
41,328 KB
testcase_40 AC 149 ms
41,456 KB
testcase_41 AC 154 ms
41,452 KB
testcase_42 AC 17 ms
7,532 KB
testcase_43 AC 23 ms
7,408 KB
testcase_44 AC 157 ms
41,576 KB
testcase_45 AC 156 ms
41,452 KB
testcase_46 AC 12 ms
7,404 KB
testcase_47 AC 3 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 82 ms
38,000 KB
testcase_50 AC 85 ms
38,124 KB
testcase_51 AC 75 ms
24,044 KB
testcase_52 AC 73 ms
23,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
const ll mo=924844033;

int len0[3030303];
ll dp[3030303];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	
	if(count(ALL(S),'1')==0) {
		cout<<S.size()<<endl;
		return;
	}
	
	int lef=1;
	while(S.back()=='0') {
		S.pop_back();
		lef++;
	}
	
	N=S.size();
	int cur=0;
	FOR(i,N) {
		if(S[i]=='0') {
			cur++;
		}
		else {
			len0[i]=cur+1;
			cur=0;
		}
	}
	map<int,ll> tar;
	ll sum=lef;
	for(i=N-1;i>=0;i--) if(S[i]=='1') {
		dp[i]=sum;
		int pre=0;
		
		while(tar.size()) {
			x=tar.begin()->first;
			y=tar.begin()->second;
			if(x<=len0[i]) {
				(sum-=1LL*(x-pre)*y)%=mo;
				pre=x;
				tar.erase(tar.begin());
			}
			else {
				(sum-=1LL*(len0[i]-pre)*y)%=mo;
				break;
			}
		}
		sum=(sum+mo+len0[i]*dp[i])%mo;
		tar[len0[i]]=dp[i];
	}
	
	cout<<(tar.begin()->first)*(ll)(tar.begin()->second)%mo<<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;
}
0