結果

問題 No.232 めぐるはめぐる (2)
ユーザー imulanimulan
提出日時 2016-12-09 23:11:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 2,263 bytes
コンパイル時間 1,614 ms
コンパイル使用メモリ 170,580 KB
実行使用メモリ 8,816 KB
最終ジャッジ日時 2023-10-12 13:47:23
合計ジャッジ時間 3,025 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    cin.tie(0);ios::sync_with_stdio(false);

    int t,a,b;
    cin >>t >>a >>b;

    bool ok=true;
    vector<string> ans;

    if(a==0 && b==0)
    {
        if(t==1) ok=false;
        else
        {
            if(t%2==1)
            {
                ans.pb(">");
                ans.pb("^");
                ans.pb("<v");
                t-=3;
            }

            while(t>0)
            {
                ans.pb(">");
                ans.pb("<");
                t-=2;
            }
        }
    }
    else
    {
        int min_dist = max(a,b);
        if(min_dist>t) ok=false;
        else
        {
            if(min_dist%2 == t%2)
            {
                int m=min(a,b);
                rep(i,m) ans.pb(">^");

                string tmp=(a>b)?"^":">";
                rep(i,min_dist-m) ans.pb(tmp);

                t-=min_dist;
            }
            else
            {
                if(a==0)
                {
                    ans.pb("^");
                    ans.pb(">v");
                    rep(i,b-1) ans.pb(">");
                    t-=b+1;
                }
                else if(b==0)
                {
                    ans.pb(">");
                    ans.pb("<^");
                    rep(i,a-1) ans.pb("^");
                    t-=a+1;
                }
                else
                {
                    ans.pb(">");
                    ans.pb("^");
                    int m=min(a,b);
                    rep(i,m-1) ans.pb(">^");
                    string tmp=(a>b)?"^":">";
                    rep(i,min_dist-m) ans.pb(tmp);
                    t-=min_dist+1;
                }

            }

            while(t>0)
            {
                ans.pb(">");
                ans.pb("<");
                t-=2;
            }
        }
    }

    if(!ok) cout << "NO" << '\n';
    else
    {
        cout << "YES" << '\n';
        rep(i,ans.size()) cout << ans[i] << '\n';
    }
    return 0;
}
0