結果

問題 No.232 めぐるはめぐる (2)
ユーザー ngtkanangtkana
提出日時 2020-04-06 00:17:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,465 bytes
コンパイル時間 2,274 ms
コンパイル使用メモリ 207,284 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-18 00:52:52
合計ジャッジ時間 4,424 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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;
    std::swap(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{"^<",">"}:vec{"^>","v",">"})
            :(x?vec{"^>"}:y?vec{"^"}:vec{"^","v"});
        assert(0<=x&&0<=y);
        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