結果

問題 No.438 Cwwプログラミング入門
ユーザー mamekin
提出日時 2016-10-28 23:16:16
言語 C++14
(gcc 8.3.0)
結果
AC  
実行時間 4 ms
コード長 1,972 Byte
コンパイル時間 775 ms
使用メモリ 1,580 KB
最終ジャッジ日時 2019-10-12 14:16:52

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
0_sample_1.txt AC 3 ms
1,572 KB
0_sample_2.txt AC 4 ms
1,568 KB
0_sample_3.txt AC 3 ms
1,504 KB
1_smalllarge01.txt AC 4 ms
1,504 KB
1_smalllarge02.txt AC 3 ms
1,508 KB
1_smalllarge03.txt AC 3 ms
1,504 KB
1_smalllarge04.txt AC 4 ms
1,504 KB
1_smalllarge05.txt AC 3 ms
1,504 KB
1_smallmiddle01.txt AC 3 ms
1,572 KB
1_smallmiddle02.txt AC 3 ms
1,576 KB
1_smallmiddle03.txt AC 3 ms
1,564 KB
1_smallmiddle04.txt AC 3 ms
1,564 KB
1_smallmiddle05.txt AC 3 ms
1,564 KB
1_smallmiddle06.txt AC 3 ms
1,504 KB
1_smallmiddle07.txt AC 3 ms
1,568 KB
1_smallmiddle08.txt AC 3 ms
1,504 KB
1_smallmiddle09.txt AC 4 ms
1,572 KB
1_smallmiddle10.txt AC 4 ms
1,560 KB
1_smallmiddle11.txt AC 3 ms
1,504 KB
1_smallmiddle12.txt AC 3 ms
1,508 KB
1_smallmiddle13.txt AC 3 ms
1,572 KB
1_smallmiddle14.txt AC 3 ms
1,576 KB
1_smallmiddle15.txt AC 4 ms
1,560 KB
1_smallmiddle16.txt AC 4 ms
1,564 KB
1_smallmiddle17.txt AC 4 ms
1,508 KB
1_smallmiddle18.txt AC 3 ms
1,572 KB
1_smallmiddle19.txt AC 3 ms
1,564 KB
1_smallmiddle20.txt AC 3 ms
1,508 KB
1_smallsmall01.txt AC 3 ms
1,580 KB
1_smallsmall02.txt AC 3 ms
1,564 KB
1_smallsmall03.txt AC 3 ms
1,508 KB
1_smallsmall04.txt AC 3 ms
1,564 KB
1_smallsmall05.txt AC 4 ms
1,564 KB
1_smallsmall06.txt AC 3 ms
1,568 KB
1_smallsmall07.txt AC 4 ms
1,564 KB
1_smallsmall08.txt AC 3 ms
1,568 KB
1_smallsmall09.txt AC 3 ms
1,564 KB
1_smallsmall10.txt AC 4 ms
1,568 KB
1_smallsmall11.txt AC 3 ms
1,504 KB
1_smallsmall12.txt AC 4 ms
1,572 KB
1_smallsmall13.txt AC 4 ms
1,508 KB
1_smallsmall14.txt AC 3 ms
1,576 KB
1_smallsmall15.txt AC 4 ms
1,564 KB
1_smallsmall16.txt AC 3 ms
1,508 KB
1_smallsmall17.txt AC 3 ms
1,576 KB
1_smallsmall18.txt AC 3 ms
1,572 KB
1_smallsmall19.txt AC 3 ms
1,568 KB
1_smallsmall20.txt AC 3 ms
1,564 KB
2_middlemiddle01.txt AC 3 ms
1,560 KB
2_middlemiddle02.txt AC 3 ms
1,552 KB
2_middlemiddle03.txt AC 3 ms
1,508 KB
2_middlemiddle04.txt AC 2 ms
1,504 KB
2_middlemiddle05.txt AC 3 ms
1,556 KB
2_middlemiddle06.txt AC 4 ms
1,560 KB
2_middlemiddle07.txt AC 4 ms
1,504 KB
2_middlemiddle08.txt AC 3 ms
1,564 KB
2_middlemiddle09.txt AC 3 ms
1,564 KB
2_middlemiddle10.txt AC 3 ms
1,548 KB
2_middlemiddle11.txt AC 4 ms
1,504 KB
2_middlemiddle12.txt AC 3 ms
1,568 KB
2_middlemiddle13.txt AC 4 ms
1,540 KB
2_middlemiddle14.txt AC 3 ms
1,576 KB
2_middlemiddle15.txt AC 3 ms
1,504 KB
2_middlemiddle16.txt AC 4 ms
1,568 KB
2_middlemiddle17.txt AC 4 ms
1,556 KB
2_middlemiddle18.txt AC 3 ms
1,504 KB
2_middlemiddle19.txt AC 3 ms
1,568 KB
2_middlemiddle20.txt AC 3 ms
1,504 KB
3_large01.txt AC 3 ms
1,524 KB
3_large02.txt AC 3 ms
1,532 KB
3_large03.txt AC 4 ms
1,528 KB
3_large04.txt AC 3 ms
1,528 KB
3_large05.txt AC 3 ms
1,528 KB
3_large06.txt AC 3 ms
1,528 KB
3_large07.txt AC 3 ms
1,532 KB
3_large08.txt AC 4 ms
1,528 KB
3_large09.txt AC 3 ms
1,524 KB
3_large10.txt AC 3 ms
1,532 KB
3_large11.txt AC 4 ms
1,508 KB
3_large12.txt AC 3 ms
1,508 KB
3_large13.txt AC 3 ms
1,504 KB
3_large14.txt AC 4 ms
1,504 KB
3_large15.txt AC 3 ms
1,508 KB
3_large16.txt AC 3 ms
1,508 KB
3_large17.txt AC 3 ms
1,508 KB
3_large18.txt AC 3 ms
1,504 KB
3_large19.txt AC 3 ms
1,504 KB
3_large20.txt AC 3 ms
1,504 KB
4_hand_1.txt AC 3 ms
1,532 KB
4_hand_2.txt AC 3 ms
1,560 KB
4_hand_3.txt AC 3 ms
1,508 KB
4_hand_4.txt AC 3 ms
1,560 KB
4_hand_5.txt AC 3 ms
1,556 KB
4_hand_6.txt AC 3 ms
1,508 KB
4_hand_7.txt AC 3 ms
1,508 KB
4_hand_8.txt AC 3 ms
1,568 KB
4_hand_9.txt AC 3 ms
1,504 KB
4_hand_10.txt AC 3 ms
1,576 KB
system_test1.txt AC 3 ms
1,504 KB
system_test2.txt AC 4 ms
1,504 KB
system_test3.txt AC 4 ms
1,556 KB
テストケース一括ダウンロード

ソースコード

diff #
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MAX = 10000;

string solve(int x, int y)
{
    if(x < 0){
        string s = solve(y, x);
        for(unsigned i=0; i<s.size(); ++i){
            if(s[i] == 'c')
                s[i] = 'w';
            else if(s[i] == 'w')
                s[i] = 'c';
        }
        return s;
    }

    string ans;
    if(x == 0 && y == 0){
        ans = "ccW";
    }
    else if(y < 0){
        if(x == 0){
            ans = string(-y, 'w') + "ccW" + string(-y, 'W');
        }
        else{
            ans = string(-y, 'w') + string(x, 'c') +
                  string(x - 1, 'C') + string(-y, 'W');
        }
    }
    else{
        ans = string(x, 'c') + string(y, 'w') +
              string(x + y - 1, 'C');
    }
    return ans;
}

int main()
{
    long long x, y, z;
    cin >> x >> y >> z;
    if(x == 0 && y == 0){
        if(z == 0)
            cout << "c" << endl;
        else
            cout << "mourennaihasimasenn" << endl;
        return 0;
    }

    for(int i=-MAX; i<=MAX; ++i){
        long long a = z - x * i;
        long long j;
        if(y == 0){
            if(a != 0)
                continue;
            j = 0;
        }
        else{
            if(a % y != 0)
                continue;
            j = a / y;
            if((abs(i) + abs(j)) * 2 - 1 > MAX)
                continue;
        }

        string ans = solve(i, j);
        if(ans.size() > MAX)
            continue;

        cout << ans << endl;
        return 0;
    }

    cout << "mourennaihasimasenn" << endl;
    return 0;
}
0