結果

問題 No.438 Cwwプログラミング入門
ユーザー しらっ亭しらっ亭
提出日時 2016-10-28 23:19:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,419 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 172,972 KB
実行使用メモリ 814,704 KB
最終ジャッジ日時 2024-05-03 17:00:04
合計ジャッジ時間 9,824 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

// ax+by=gcd(a,b) を満たす x,y を求める。戻り値は gcd(a,b)
long long extgcd(long long a, long long b, long long& x, long long& y) {
  long long g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

void panic() {
  cout << "mourennaihasimasenn" << endl;
  exit(0);
}

string minu(char c, int n) {
  string ret;
  rep(i, n) {
    ret += c;
    ret += 'W';
  }
  return ret;
}

string neg(char c, int n) {
  string ret;
  rep(i, n+2) ret += c;
  rep(i, n) ret += 'C';
  ret += 'W';
  return ret;
}

string pos(char c, int n) {
  string ret;
  rep(i, n) ret += c;
  rep(i, n-1) ret += 'C';
  return ret;
}

string solve() {
  int c = read<int>();
  int w = read<int>();
  int Z = read<int>();

  ll nc, nw;

  ll g = extgcd(c, w, nc, nw);
  if (Z % g != 0) {
    panic();
  }

  if (nc == 0 && nw == 0) {
    return "";
  }

  //cout<<"g: "<<g<<endl;
  //cout<<"nc: "<<nc<<endl;
  //cout<<"nw: "<<nw<<endl;

  nc *= (Z/g);
  nw *= (Z/g);

  //cout<<"nc: "<<nc<<endl;
  //cout<<"nw: "<<nw<<endl;

  if (nc == 0) {
    if (nw < 0) {
      int len = 2 * -nw + 3;
      if (len > 10000) panic();
      return neg('w', -nw);
    }
    else {
      int len = 2 * nw -1;
      if (len > 10000) panic();
      return pos('w', nw);
    }
  }
  if (nw == 0) {
    if (nc < 0) {
      int len = 2 * -nc + 3;
      if (len > 10000) panic();
      return neg('c', -nc);
    }
    else {
      int len = 2 * nc -1;
      if (len > 10000) panic();
      return pos('c', nc);
    }
  }

  if (nc > 0 && nw > 0) {
    string ret;
    int len = 2 * nc - 1 + 2 * nw - 1 + 1;
    if (len > 10000) panic();
    ret += pos('c', nc);
    ret += pos('w', nw);
    ret += 'C';
    return ret;
  }
  if (nc > 0 && nw < 0) {
    string ret;
    int len = 2 * nc - 1 + 2 * nw;
    if (len > 10000) panic();
    ret += pos('c', nc);
    ret += minu('w', -nw);
    return ret;
  }
  if (nc < 0 && nw > 0) {
    string ret;
    int len = 2 * nw - 1 + 2 * nc;
    if (len > 10000) panic();
    ret += pos('w', nw);
    ret += minu('c', -nc);
    return ret;
  }
  if (nc < 0 && nw < 0) {
    string ret;
    int len = 2 * nc - 1 + 2 * nw;
    if (len > 10000) panic();
    ret += neg('c', nc);
    ret += minu('w', -nw);
    return ret;
  }
  assert(false);
}

void Main() {
  cout << solve() << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }
0