結果

問題 No.2037 NAND Pyramid
ユーザー keisuke6keisuke6
提出日時 2022-08-12 22:58:31
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,037 bytes
コンパイル時間 3,513 ms
コンパイル使用メモリ 253,540 KB
実行使用メモリ 812,452 KB
最終ジャッジ日時 2023-10-24 11:17:53
合計ジャッジ時間 6,414 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 MLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int N,K;
pair<vector<int>,int> f(int n, int k, vector<int> &S, int x){
    if(n == k) return {S,x};
    vector<int> A={};
    int now = 0;
    for(int i=0;i<S.size();i++){
        if(i != 0) now++;
        if(S[i] == 1) continue;
        if(S[i] != 1 && (x+i)%2 == 1){
            if(now != 0) A.push_back(now);
            A.push_back(S[i]-1);
            now = 0;
        }
        else now += S[i]-1;
    }
    if(now != 0) A.push_back(now);
    int a = 1-(S[0] > 1 && x == 1);
    S = {};
    return f(n-1,k,A,a);
}
int main(){
  cin>>N>>K;
  vector<int> S={};
  for(int i=0;i<N;i++){
      char a;
      cin>>a;
      S.push_back(a-'0');
  }
  vector<int> T={};
  int now = 1;
  for(int i=1;i<N;i++){
      if(S[i] != S[i-1]){
          T.push_back(now);
          now=1;
      }
      else now++;
  }
  T.push_back(now);
  pair<vector<int>,int> z = f(N,K,T,S[0]);
  int a;
  tie(S,a) = z;
  for(int i=0;i<S.size();i++){
      for(int j=0;j<S[i];j++) cout<<(a+i)%2;
  }
  cout<<endl;
}
0