結果

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

テストケース

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

ソースコード

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;}

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

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

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

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

  if (Z == 0) return "";

  rep(nnc, -10000, 10000) {
    ll rem = Z - nnc * c;
    if (rem % w == 0) {
      ll nnw = rem / w;
      int nc = nnc;
      ll nw = nnw;
      //_p("%d,%lld\n", nc, nw);
      if (nc == 0) {
        if (nw < 0) {
          nw = -nw;
          ll len = 2 * nw + 3;
          if (len > 10000) continue;
          string ret;
          neg('w', nw, ret);
          return ret;
        }
        else {
          ll len = 2 * nw -1;
          if (len > 10000) continue;
          string ret;
          pos('w', nw, ret);
          return ret;
        }
      }
      else if (nw == 0) {
        if (nc < 0) {
          nc = -nc;
          ll len = 2 * -nc + 3;
          if (len > 10000) continue;
          string ret;
          neg('c', nc, ret);
          return ret;
        }
        else {
          ll len = 2 * nc -1;
          if (len > 10000) continue;
          string ret;
          pos('c', nc, ret);
          return ret;
        }
      }

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

  return "";

  assert(false);
}

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