結果

問題 No.438 Cwwプログラミング入門
ユーザー motimoti
提出日時 2016-10-29 20:55:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,791 bytes
コンパイル時間 1,783 ms
コンパイル使用メモリ 172,224 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-16 09:15:01
合計ジャッジ時間 13,113 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

ll x, y, z;

namespace math { namespace integer {

template<class value_type> value_type mod_mul(value_type x, value_type k, ll m) { if(k == 0) { return 0; } if(k % 2 == 0) { return mod_mul((x+x) % m, k/2, m); } else { return (x + mod_mul(x, k-1, m)) % m; } }
template<class value_type> value_type mod_pow(value_type x, value_type n, ll mod) { if(n == 0) { return 1; } if(n % 2 == 0) { return mod_pow(mod_mul(x, x, mod) % mod, n / 2, mod); } else { return mod_mul(x, mod_pow(x, n - 1, mod), mod); } }
template<class value_type> value_type extgcd(value_type a, value_type b, value_type& x, value_type& y) { value_type d = a; if(b != 0) { d = extgcd(b, a%b, y, x); y -= (a / b) * x;} else { x = 1, y = 0; } return d; }
template<class value_type> value_type mod_inverse(value_type x, ll mod) { return mod_pow(x, value_type(mod-2), mod); /* use fermat */ }
template<class value_type> value_type mod_inverse_composite_num_mod(value_type a, ll mod) { value_type x, y; extgcd(a, mod, x, y); return (mod + x % mod) % mod; }

}}
using namespace math::integer;

const char* ng = "mourennaihasimasenn";

const int Lim = 10000;
ll X, Y, g;

/*
void minimumShow(char c, ll x) {
  while(x > 0) {
    if(x & 1) {
      ans.push_back(c);
    }
    if(!ans.empty() && ans.back() == c) {
      ans += 'C';
    }
    x >>= 1;
  }
}
*/

bool verify(string& ans) {
  deque<ll> st;
  for(auto c: ans) {
    if(c == 'c') st.push_back(x);
    if(c == 'w') st.push_back(y);
    if(c == 'C') {
      if(st.empty()) return false;
      auto a = st.back(); st.pop_back();
      if(st.empty()) return false;
      auto b = st.back(); st.pop_back();
      st.push_back(a + b);
    }
    if(c == 'W') {
      if(st.empty()) return false;
      auto a = st.back(); st.pop_back();
      if(st.empty()) return false;
      auto b = st.back(); st.pop_back();
      st.push_back(a - b);
    }
//    for(auto e: st) cout << e << ", "; cout << endl;
  }

  if(st.size() != 1) return false;
  if(st.back() != z) return false;

  return true;
}

bool makeLast(string& ans) {
  int xp = 0, yp = 0;

  rep(i, -X) {
    ans += 'c';
    if(X > 0) ans += 'c', xp++;
    else if(Y > 0) ans += 'w', yp++;
    ans += 'W';
  }

  rep(i, -Y) {
    ans += 'w';
    if(X > 0) ans += 'c', xp++;
    else if(Y > 0) ans += 'w', yp++;
    ans += 'W';
  }

  rep(i, X - xp) ans += 'c';
  rep(i, Y - yp) ans += 'w';

  string t = ans;
  cout << "T = " << t << endl;
  rep(i, z / g - 1) ans += t;
  rep(i, z / g - 1) ans += 'C';

  return true;
}

int main() {

  cin >> x >> y >> z;

  if(z == 0)
    return printf("ccW\n");

  if(x == 0 || y == 0)
    return printf("%s", ng);

  for(int i=-5000; i<=5000; i++) {
    ll b = z - x * i;
    if(b % y) continue;
    ll c = b / y;
    if((abs(i) + abs(c)) * 2 - 1 > 10000) continue;

    if(i > 0 && c > 0) {
      cout << string(i, 'c') << string(c, 'w') << string(i + c - 1, 'C') << endl;
      return 0;
    }
    if(i < 0) {
      cout << string(abs(i), 'c') << string(abs(i) - 1, 'c') << string(c, 'w') << string(abs(c) - 1, 'C') << "W" << endl;
      return 0;
    }
    if(c < 0) {
      cout << string(abs(c), 'w') << string(abs(c) - 1, 'c') << string(abs(i), 'c') << string(abs(i) - 1, 'C') << "W" << endl;
      return 0;
    }
  }

  return printf("%s", ng);
}
0