結果

問題 No.438 Cwwプログラミング入門
ユーザー btkbtk
提出日時 2016-04-29 17:42:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,939 bytes
コンパイル時間 1,886 ms
コンパイル使用メモリ 174,564 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-03 15:58:38
合計ジャッジ時間 12,514 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,248 KB
testcase_01 AC 4 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 5 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 4 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 4 ms
5,376 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 4 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 4 ms
5,376 KB
testcase_33 AC 4 ms
5,376 KB
testcase_34 AC 4 ms
5,376 KB
testcase_35 AC 3 ms
5,376 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 4 ms
5,376 KB
testcase_38 AC 3 ms
5,376 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 3 ms
5,376 KB
testcase_41 AC 4 ms
5,376 KB
testcase_42 AC 4 ms
5,376 KB
testcase_43 AC 3 ms
5,376 KB
testcase_44 AC 4 ms
5,376 KB
testcase_45 AC 3 ms
5,376 KB
testcase_46 AC 3 ms
5,376 KB
testcase_47 AC 4 ms
5,376 KB
testcase_48 AC 4 ms
5,376 KB
testcase_49 AC 4 ms
5,376 KB
testcase_50 AC 3 ms
5,376 KB
testcase_51 WA -
testcase_52 AC 4 ms
5,376 KB
testcase_53 AC 4 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 4 ms
5,376 KB
testcase_56 AC 4 ms
5,376 KB
testcase_57 AC 4 ms
5,376 KB
testcase_58 AC 4 ms
5,376 KB
testcase_59 AC 4 ms
5,376 KB
testcase_60 AC 4 ms
5,376 KB
testcase_61 AC 3 ms
5,376 KB
testcase_62 AC 3 ms
5,376 KB
testcase_63 AC 5 ms
5,376 KB
testcase_64 AC 4 ms
5,376 KB
testcase_65 AC 3 ms
5,376 KB
testcase_66 AC 3 ms
5,376 KB
testcase_67 AC 3 ms
5,376 KB
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 RE -
testcase_73 RE -
testcase_74 RE -
testcase_75 RE -
testcase_76 RE -
testcase_77 RE -
testcase_78 RE -
testcase_79 RE -
testcase_80 RE -
testcase_81 RE -
testcase_82 RE -
testcase_83 RE -
testcase_84 RE -
testcase_85 RE -
testcase_86 RE -
testcase_87 RE -
testcase_88 AC 3 ms
5,376 KB
testcase_89 AC 4 ms
5,376 KB
testcase_90 WA -
testcase_91 AC 4 ms
5,376 KB
testcase_92 WA -
testcase_93 AC 3 ms
5,376 KB
testcase_94 AC 2 ms
5,376 KB
testcase_95 WA -
testcase_96 AC 3 ms
5,376 KB
testcase_97 RE -
testcase_98 RE -
testcase_99 RE -
testcase_100 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
* Problem link
* http://yukicoder.me/problems/1100
*/

#include<bits/stdc++.h>
using namespace std;

struct INIT{INIT(){cin.tie(0);ios_base::sync_with_stdio(false);} }init;

typedef long long LL;
inline bool inner(LL x,LL lb,LL ub) {
	return(lb <= x && x <= ub);
}
#define SZ 100000
pair<char, char> _used[SZ * 2 + 1];


/*小さいケースならBFSで最適解が求まる*/

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	LL x, y, z;
	cin >> x >> y >> z;
	assert(inner(x, 0, 100000000));
	assert(inner(y, 0, 100000000));
	assert(inner(z, 0, 100000000));

	fill(_used, _used + SZ * 2 + 1, make_pair('-', '-'));
	pair<char, char> *used = _used + SZ;
	queue<LL> que;
	used[x] = make_pair('c', '-');
	used[y] = make_pair('w', '-');
	que.push(x);
	que.push(y);

	while (que.empty() == false) {
		auto v = que.front();que.pop();
		if (inner(v + x, -SZ, SZ) && used[v + x].first == '-') {
			used[v + x] = make_pair('c', 'C');
			que.push(v + x);
		}
		if (inner(v - x, -SZ, SZ) && used[v - x].first == '-') {
			used[v - x] = make_pair('c', 'W');
			que.push(v - x);
		}
		if (inner(v + y, -SZ, SZ) && used[v + y].first == '-') {
			used[v + y] = make_pair('w', 'C');
			que.push(v + y);
		}
		if (inner(v - y, -SZ, SZ) && used[v - y].first == '-') {
			used[v - y] = make_pair('w', 'W');
			que.push(v - y);
		}
	}
	if (inner(z, -SZ, SZ) == false || used[z].first == '-') {
		cout << "mourennaihasimasenn" << endl;
		return 0;
	}
	LL v = z;
	string p, q;
	while (true) {
		p += used[v].first;
		if (used[v].second == '-')break;
		q += used[v].second;
			 if (used[v].first == 'c'&&used[v].second == 'C')v = v - x;
		else if (used[v].first == 'c'&&used[v].second == 'W')v = v + x;
		else if (used[v].first == 'w'&&used[v].second == 'C')v = v - y;
		else if (used[v].first == 'w'&&used[v].second == 'W')v = v + y;
	};
	reverse(q.begin(), q.end());
	cout << p + q << endl;
	return 0;
}
0