Educational Codeforces Round 101 E問題
Problem description
省略
省略
C++に変換後のコードはこちら
//no-unlocked
int N, K; char S[1d6+2], res[1d6+2];
{
HashMap<ull,int> mp;
rollingHash h;
rollingHashSubarrays arr;
REP(rd_int()){
rd(N,K,S);
rep(i,N) S[i] = (S[i] - '0') ^ 1;
arr.set(N, S);
mp.init(N-K+1);
rep(i,N-K+1) mp[arr.get_len(i,K).hs] = 1;
rep(i,K) res[i] = 0;
h = calcRollingHash(K, res);
for(;;){
if(!mp.exist(h.hs)){
wt("YES");
rep(i,K) res[i] += '0';
res[K] = '\0';
wt(res);
break;
}
rrep(i,K) if(res[i] == 0) break;
if(i==-1) wt("NO"), break;
res[i] = 1; h.change(i, 0, 1);
rep(j,i+1,K) res[j] = 0, h.change(j, 1, 0);
}
}
}
Current time: 2024年03月29日08時36分15秒
Last modified: 2020年12月29日16時15分32秒 (by laycrs)
Tags: Competitive_Programming_Incomplete Codeforces
トップページに戻る
Logged in as: unknown user (not login)