結果

問題 No.438 Cwwプログラミング入門
ユーザー tossytossy
提出日時 2016-10-29 11:32:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,282 bytes
コンパイル時間 964 ms
コンパイル使用メモリ 98,880 KB
実行使用メモリ 27,872 KB
最終ジャッジ日時 2024-05-03 19:24:40
合計ジャッジ時間 8,227 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600


// a*x + b*y = gcd(a, b)
int extgcd(int a, int b, int& x, int& y){
  int d=a;
  if(b!=0){
    d=extgcd(b, a%b, y, x);
    y-=(a/b)*x;
  } else {
    x=1; y=0;
  }
  return d;
}

bool solve(){
  int x,y,z;
  cin>>x>>y>>z;

  int a,b;
  int g = extgcd(x, y, a, b);
  // ax + by = g

  if(z==0){
    if(x==y){cout<<"cwW"<<endl;return true;}
    if(x==0){cout<<"c"<<endl; return true;}
    if(y==0){cout<<"w"<<endl; return true;}
    else return false;
  }

  if(z%g!=0 || (a==0 && b==0)){
    return false;
  }

  string push="", pop="";
  bool flg=false;
  string xx="c", yy="w";
  if(x<y){ swap(x,y); swap(xx,yy); }
  if(x!=0 && z > x){
    if(z/x > 5010) return false;
    rep(i, z/x){
      push += xx;
      pop += "C";
    }
    z = z%x;
    flg=true;
  }
  if(y!=0 && z > y){
    if(pop.size() + z/y > 5010) return false;
    rep(i, z/y){
      push += yy;
      pop += "C";
    }
    z = z%y;
    flg=true;
  }
  if(z==0){
    if(push.size() + pop.size()-1 > 10000) return false;
    cout<<push<<pop.substr(1)<<endl;
    return true;
  }
  string res;
  if(flg) res = push + pop.substr(1);

  if(res.size() + z/g*2*abs(a+b) > 10050) return false;

  push="";pop="";
  if(a<0){
    rep(i,-a) push += "c";
    rep(i,-a) pop = "W" + pop;
  }
  if(b<0){
    rep(i,-b) push += "w";
    rep(i,-b) pop = "W" + pop;
  }
  if(a>0){
    rep(i,a) push += "c";
    rep(i,a) pop = "C"+pop;
  }
  if(b>0){
    rep(i,b) push += "w";
    rep(i,b) pop = "C"+pop;
  }
  pop = pop.substr(1);

  rep(i,z/g){
    res += push + pop;
    if(i!=0) res += "C";
  }
  if(flg) res += "C";

  if(res.size()>10000) return false;
  else cout<<res<<endl;
  return true;
}

int main(){
  if(!solve()) cout<<"mourennaihasimasenn"<<endl;

  return 0;
}
0