結果

問題 No.1376 Simple LPS Problem
ユーザー 沙耶花
提出日時 2021-02-05 22:22:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 875 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 195,376 KB
最終ジャッジ日時 2025-01-18 12:36:28
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 53 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 10000000000000001


int main(){
	
	int N,K;
	cin>>N>>K;
	
	if((N+1)/2 <= K){
		string ans(N,'1');
		rep(i,K)ans[i] = '0';
		cout<<ans<<endl;
	}
	else{
		string s = "";
		
		int x = (K-1)/2 + 1;
		int y = 1;
		if(K%2==0)y++;
		
		while(s.size()<=N){
			if(x<=0)break;
			rep(i,x){
				s += '0';
			}
			x--;
			if(K%2==0){
				if(x==0){
					y = K/2-1;
					rep(i,y){
						s += '1';
					}
					break;
				}
			}
			rep(i,y){
				s += '1';
			}
			
			y++;
			
		}
		
		if(K==4){
			s += '1';
		}
		else if(K>4){
			string t(K,'1');
			s = t+s;
			char c = s.back();
			if(c=='0')c = '1';
			else c = '0';
			rep(i,K){
				s += c;
			}
		}
		
		if(s.size()<N){
			cout<<-1<<endl;
			return 0;
		}
		cout<<s.substr(0,N)<<endl;
		
		
	}
	
	
	return 0;
}
0