結果

問題 No.2247 01 ZigZag
ユーザー batasanblogbatasanblog
提出日時 2023-03-18 09:28:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,888 bytes
コンパイル時間 5,827 ms
コンパイル使用メモリ 267,812 KB
実行使用メモリ 7,024 KB
最終ジャッジ日時 2023-10-18 20:18:30
合計ジャッジ時間 5,806 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 6 ms
5,868 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 4 ms
4,644 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 6 ms
5,532 KB
testcase_09 AC 7 ms
6,084 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 4 ms
4,696 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 3 ms
4,372 KB
testcase_17 AC 9 ms
6,908 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 3 ms
4,348 KB
testcase_22 AC 6 ms
5,424 KB
testcase_23 AC 4 ms
4,368 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 6 ms
5,644 KB
testcase_26 AC 4 ms
4,756 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 7 ms
6,328 KB
testcase_29 AC 7 ms
6,568 KB
testcase_30 AC 7 ms
6,140 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 4 ms
5,924 KB
testcase_33 AC 3 ms
4,868 KB
testcase_34 AC 3 ms
4,368 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 4 ms
5,132 KB
testcase_37 AC 3 ms
4,348 KB
testcase_38 AC 3 ms
4,348 KB
testcase_39 AC 3 ms
4,560 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 8 ms
7,024 KB
testcase_46 AC 8 ms
7,024 KB
testcase_47 AC 2 ms
4,348 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 1 ms
4,348 KB
testcase_50 AC 2 ms
4,348 KB
testcase_51 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
//using mint = static_modint<998244353>;
//using mint = modint;
using mint = static_modint<1000000007>;
using vm = vector<mint>;
using vvm = vector<vm>;
ostream &operator<<(ostream &o,const mint &m){cout<<m.val();return o;}
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);++i)
#define reps(i,s,n) for(ll i=(s);i<(ll)(n);++i)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);++i)
#define ts(i) to_string(i)
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const long long INF = 1e18;

#ifdef DEBUG
#include <debug.hpp>
#endif
string solve(){
	ll N,M,K;
	cin >> N>>M>>K;

#ifdef DEBUG
	cout<<"N="<<N<<" M="<<M<<" K="<<K<<endl;
#endif
	string s="";
	if(K==0){
		if(N>0&&M>0) return "-1";
		if(N>0){
			rep(i,N)s+='0';
		}else{
			rep(i,M)s+='1';
		}
		return s;
	}
	ll a,b;
	if(K%2){
		a=(K+1)/2;b=(K+1)/2;
	}else{
		a=K/2+1;b=K/2;
	}
#ifdef DEBUG
	cout<<"a="<<a<<" b="<<b<<endl;
#endif
	//if(a>N||b>M)return "-1"; //N,M short
	//if(N<a&&M<a)return "-1";
	//if(N<b&&M<b)return "-1";
	if((N<a||M<b)&&(M<a||N<b))return "-1";
	string s0="",s1="";
	if(N>=a){
		vector<string> v0(a,"0"),v1(b,"1");
		rep(i,N-a){
			v0.at(0)+='0';
		}
		rep(i,M-b){
			v1.back()+='1';
		}
		rep(i,K+1){
			if(i%2)s0+=v1.at(i/2);
			else s0+=v0.at(i/2);
		}
	}
	if(M>=b){
		vector<string> w0(b,"0"),w1(a,"1");
		rep(i,M-a){
			w1.back()+='1';
		}
		rep(i,N-b){
			w0.at(0)+='0';
		}
		rep(i,K+1){
			if(i%2)s1+=w0.at(i/2);
			else s1+=w1.at(i/2);
		}
	}
	if(s0==""&&s1!="")s=s1;
	else if(s0!=""&&s1=="")s=s0;
	else if(s0<s1)s=s0;
	else s=s1;
	return s;
}

int main(){
#ifdef DEBUG
	cout << "--- Input ---" << endl;
#endif
#ifdef DEBUG
	cout << "--- Answer ---" << endl;
#endif
	cout<<solve()<<endl;
}
//cout << fixed << setprecision(9);
0