結果

問題 No.438 Cwwプログラミング入門
ユーザー anta
提出日時 2016-10-28 22:48:11
言語 C++14
(gcc 8.3.0)
結果
AC  
実行時間 157 ms
コード長 2,123 Byte
コンパイル時間 1,467 ms
使用メモリ 8,924 KB
最終ジャッジ日時 2019-10-12 14:16:27

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
0_sample_1.txt AC 24 ms
6,872 KB
0_sample_2.txt AC 29 ms
6,872 KB
0_sample_3.txt AC 150 ms
6,876 KB
1_smalllarge01.txt AC 154 ms
6,872 KB
1_smalllarge02.txt AC 153 ms
6,872 KB
1_smalllarge03.txt AC 155 ms
6,876 KB
1_smalllarge04.txt AC 151 ms
6,876 KB
1_smalllarge05.txt AC 149 ms
6,876 KB
1_smallmiddle01.txt AC 26 ms
6,872 KB
1_smallmiddle02.txt AC 7 ms
6,876 KB
1_smallmiddle03.txt AC 58 ms
6,872 KB
1_smallmiddle04.txt AC 57 ms
6,872 KB
1_smallmiddle05.txt AC 41 ms
6,876 KB
1_smallmiddle06.txt AC 152 ms
6,872 KB
1_smallmiddle07.txt AC 28 ms
6,872 KB
1_smallmiddle08.txt AC 150 ms
6,872 KB
1_smallmiddle09.txt AC 18 ms
6,876 KB
1_smallmiddle10.txt AC 36 ms
6,876 KB
1_smallmiddle11.txt AC 150 ms
6,876 KB
1_smallmiddle12.txt AC 151 ms
6,872 KB
1_smallmiddle13.txt AC 21 ms
6,872 KB
1_smallmiddle14.txt AC 25 ms
8,920 KB
1_smallmiddle15.txt AC 59 ms
6,872 KB
1_smallmiddle16.txt AC 55 ms
6,876 KB
1_smallmiddle17.txt AC 151 ms
6,872 KB
1_smallmiddle18.txt AC 21 ms
6,872 KB
1_smallmiddle19.txt AC 41 ms
8,924 KB
1_smallmiddle20.txt AC 151 ms
6,876 KB
1_smallsmall01.txt AC 3 ms
6,876 KB
1_smallsmall02.txt AC 49 ms
6,872 KB
1_smallsmall03.txt AC 150 ms
6,876 KB
1_smallsmall04.txt AC 43 ms
6,876 KB
1_smallsmall05.txt AC 49 ms
6,872 KB
1_smallsmall06.txt AC 36 ms
6,876 KB
1_smallsmall07.txt AC 3 ms
8,920 KB
1_smallsmall08.txt AC 27 ms
6,876 KB
1_smallsmall09.txt AC 27 ms
6,872 KB
1_smallsmall10.txt AC 31 ms
6,872 KB
1_smallsmall11.txt AC 152 ms
6,876 KB
1_smallsmall12.txt AC 28 ms
6,876 KB
1_smallsmall13.txt AC 152 ms
6,876 KB
1_smallsmall14.txt AC 21 ms
6,876 KB
1_smallsmall15.txt AC 39 ms
6,872 KB
1_smallsmall16.txt AC 150 ms
6,872 KB
1_smallsmall17.txt AC 21 ms
6,876 KB
1_smallsmall18.txt AC 24 ms
6,872 KB
1_smallsmall19.txt AC 28 ms
6,872 KB
1_smallsmall20.txt AC 42 ms
6,876 KB
2_middlemiddle01.txt AC 113 ms
6,876 KB
2_middlemiddle02.txt AC 58 ms
6,876 KB
2_middlemiddle03.txt AC 151 ms
6,876 KB
2_middlemiddle04.txt AC 150 ms
6,876 KB
2_middlemiddle05.txt AC 40 ms
6,872 KB
2_middlemiddle06.txt AC 89 ms
6,876 KB
2_middlemiddle07.txt AC 150 ms
6,872 KB
2_middlemiddle08.txt AC 28 ms
6,876 KB
2_middlemiddle09.txt AC 64 ms
6,872 KB
2_middlemiddle10.txt AC 65 ms
6,876 KB
2_middlemiddle11.txt AC 151 ms
6,876 KB
2_middlemiddle12.txt AC 16 ms
6,876 KB
2_middlemiddle13.txt AC 67 ms
6,876 KB
2_middlemiddle14.txt AC 6 ms
6,872 KB
2_middlemiddle15.txt AC 151 ms
6,872 KB
2_middlemiddle16.txt AC 33 ms
6,872 KB
2_middlemiddle17.txt AC 43 ms
6,876 KB
2_middlemiddle18.txt AC 152 ms
6,876 KB
2_middlemiddle19.txt AC 44 ms
6,876 KB
2_middlemiddle20.txt AC 154 ms
6,876 KB
3_large01.txt AC 3 ms
6,876 KB
3_large02.txt AC 66 ms
6,872 KB
3_large03.txt AC 66 ms
6,876 KB
3_large04.txt AC 66 ms
6,876 KB
3_large05.txt AC 66 ms
6,876 KB
3_large06.txt AC 66 ms
6,876 KB
3_large07.txt AC 66 ms
6,872 KB
3_large08.txt AC 66 ms
6,872 KB
3_large09.txt AC 3 ms
6,876 KB
3_large10.txt AC 66 ms
6,876 KB
3_large11.txt AC 151 ms
6,876 KB
3_large12.txt AC 151 ms
6,872 KB
3_large13.txt AC 150 ms
6,872 KB
3_large14.txt AC 150 ms
6,872 KB
3_large15.txt AC 152 ms
6,876 KB
3_large16.txt AC 150 ms
6,872 KB
3_large17.txt AC 157 ms
6,872 KB
3_large18.txt AC 150 ms
8,920 KB
3_large19.txt AC 151 ms
6,876 KB
3_large20.txt AC 151 ms
6,872 KB
4_hand_1.txt AC 67 ms
6,872 KB
4_hand_2.txt AC 68 ms
6,876 KB
4_hand_3.txt AC 150 ms
8,924 KB
4_hand_4.txt AC 151 ms
6,872 KB
4_hand_5.txt AC 150 ms
6,872 KB
4_hand_6.txt AC 3 ms
6,876 KB
4_hand_7.txt AC 150 ms
6,876 KB
4_hand_8.txt AC 68 ms
6,872 KB
4_hand_9.txt AC 152 ms
6,872 KB
4_hand_10.txt AC 5 ms
6,872 KB
system_test1.txt AC 152 ms
8,916 KB
system_test2.txt AC 152 ms
6,876 KB
system_test3.txt AC 93 ms
8,920 KB
テストケース一括ダウンロード

ソースコード

diff #
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int exgcd(int a, int b, int &g) {
	int u = 1, v = 0;
	while(b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	g = a;
	return u;
}

int main() {
	const int MaxLen = 10000;
	int x; int y; int z;
	while(~scanf("%d%d%d", &x, &y, &z)) {
		string ans;
		if(z == 0) {
			ans = "wwW";
			goto ok;
		}
		rer(aa, -MaxLen / 2, MaxLen / 2) rer(bb, -MaxLen / 2, MaxLen / 2) {
			ll a = aa, b = bb;
			if(a <= 0 && b <= 0) continue;
			ll len = (abs(a) + abs(b)) * 2 - 1;
			if(len > MaxLen) continue;
			if((ll)a * x + (ll)b * y != z) continue;
			if(a > 0) {
				ans += 'c';
				-- a;
			} else {
				ans += 'w';
				-- b;
			}
			string ansL;
			while(a != 0 || b != 0) {
				if(a > 0)
					ans += "cC", -- a;
				else if(a < 0)
					ansL += 'c', ans += "W", ++ a;
				else if(b > 0)
					ans += "wC", -- b;
				else
					ansL += 'w', ans += "W", ++ b;
			}
			reverse(ansL.begin(), ansL.end());
			ans = ansL + ans;
			assert(ans.size() == len);
			goto ok;
		}
	ok:;
		if(ans.empty()) {
			puts("mourennaihasimasenn");
		} else {
			puts(ans.c_str());
			/*
			vector<ll> stk;
			for(char c : ans) {
				if(c == 'c')
					stk.push_back(x);
				if(c == 'w')
					stk.push_back(y);
				if(c == 'C') {
					ll t = stk.end()[-1] + stk.end()[-2];
					stk.pop_back();
					stk.pop_back();
					stk.push_back(t);
				}
				if(c == 'W') {
					ll t = stk.end()[-1] - stk.end()[-2];
					stk.pop_back();
					stk.pop_back();
					stk.push_back(t);
				}
			}
			cerr << z << " = " << stk.back() << endl;
			*/
		}
	}
	return 0;
}
0