結果

問題 No.2037 NAND Pyramid
ユーザー pockynypockyny
提出日時 2022-08-12 22:57:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 69,008 KB
最終ジャッジ日時 2025-01-30 21:39:33
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;
int main(){
    int i,n,k; cin >> n >> k;
    string s,t; cin >> s;
    int len = n - k + 1;
    for(i=0;i<k;i++){
        if(len&1){
            if(s[i + len/2]=='1' && (s[i + len/2 - 1]!='0' || s[i + len/2 + 1]!='0')) t.push_back('1');
            else t.push_back('0');
        }else{
            if(s.substr(i + len/2 - 1,2)!="11") t.push_back('1');
            else t.push_back('0');
        }
    }
    cout << t << endl;
}
0