結果

問題 No.438 Cwwプログラミング入門
ユーザー togari_takamototogari_takamoto
提出日時 2016-10-28 23:33:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,001 bytes
コンパイル時間 1,306 ms
コンパイル使用メモリ 150,412 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-16 08:19:54
合計ジャッジ時間 14,054 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

ll extgcd(ll a, ll b, ll *x, ll *y) {
	if (b == 0) return (*x = (a<0) ? -1 : 1), *y = 0, abs(a);
	ll d = extgcd(b, a%b, y, x);
	return *y -= a / b*(*x), d;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll a, b, c; cin >> a >> b >> c;
	ll x, y;
	ll d = extgcd(a, b, &x, &y);
	auto cww = [&](ll x, ll y, ll c, const string & s) {
		string C = "c", W = "w";
		if (c % d) return false;

		x *= c / d;
		y *= c / d;

		ll ans = 0;
		if (x < 0) {
			ans += -x + y + max<ll>(0, y - 1) -x;
		} else if (y < 0) {
			ans += -y + x + max<ll>(0, x - 1) - y;
		} else {
			ans += x + y + max<ll>(0, x - 1 + y);
		}
		if (s.size() + ans <= 10000) {
			string ans;
			if (x < 0) {
				REP(i, -x) ans += C;
				REP(i, y) ans += W;
				REP(i, y - 1) ans += "C";
				REP(i, -x) ans += "W";
			} else if (y < 0) {
				REP(i, -y) ans += W;
				REP(i, x) ans += C;
				REP(i, x - 1) ans += "C";
				REP(i, -y) ans += "W";
			} else {
				REP(i, x) ans += C;
				REP(i, y) ans += W;
				REP(i, y + x - 1) ans += "C";
			}
			cout << s << ans << endl;
			return true;
		}
		return false;
	};
	string s;
	REP(i, c / a) {
		if (s.size() >= 10000) break;
		if (cww(x, y, c - i*a, s)) return 0;
		if (i == 0) s = "c";
		s += "cC";
	}

	s = "" ;
	REP(i, c / b) {
		if (s.size() >= 10000) break;
		if (cww(x, y, c - i*b, s)) return 0;
		if (i == 0) s = "w";
		s += "wC";
	}
	cout << "mourennaihasimasenn" << endl;

	return 0;
}
0