結果

問題 No.232 めぐるはめぐる (2)
ユーザー ngtkanangtkana
提出日時 2020-04-06 00:07:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,417 bytes
コンパイル時間 2,211 ms
コンパイル使用メモリ 206,908 KB
実行使用メモリ 9,316 KB
最終ジャッジ日時 2023-09-17 23:44:13
合計ジャッジ時間 4,736 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
8,272 KB
testcase_01 AC 16 ms
9,020 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
lint cabs(lint&x){return x<0?x=-x,1:0;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint T,x,y;std::cin>>T>>x>>y;
    lint sx=cabs(x),sy=cabs(y);
    if(x==0&&y==0&&T==1||T<std::max(x,y)){
        std::cout<<"NO"<<'\n';
        return 0;
    }
    lint sxy=x>y?std::swap(x,y),1:0;
    std::vector<std::string>ans;
    auto mvchar=[&](char c){
        if(c=='<')x++;
        if(c=='>')x--;
        if(c=='v')y++;
        if(c=='^')y--;
    };
    auto mvstr=[&](std::string const&s){
        T--;
        for(char c:s)mvchar(c);
        ans.push_back(s);
    };
    while(T){
        using vec=std::vector<std::string>;
        vec v=(T-std::max(x,y))%2
            ?(x?vec{"^",">"}:y?vec{"^","V>"}:vec{"^",">","v<"})
            :(x?vec{"^>"}:y?vec{">"}:vec{"^","v"});
        for(std::string&s:v)mvstr(s);
    }
    auto replace=[&](char&c,char c0,char c1){
        if(c==c0)c=c1;
        else if(c==c1)c=c0;
    };
    for(auto&&s:ans)for(char&c:s){
        if(sx)replace(c,'<','>');
        if(sy)replace(c,'v','^');
        if(sxy){
            replace(c,'^','>');
            replace(c,'v','<');
        }
    }
    std::cout<<"YES"<<'\n';
    for(auto&&s:ans){
        std::cout<<s<<'\n';
    }
}
0