結果
| 問題 | No.232 めぐるはめぐる (2) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-12-09 23:11:30 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 12 ms / 1,000 ms | 
| コード長 | 2,263 bytes | 
| コンパイル時間 | 1,781 ms | 
| コンパイル使用メモリ | 173,392 KB | 
| 実行使用メモリ | 7,524 KB | 
| 最終ジャッジ日時 | 2024-09-14 12:43:48 | 
| 合計ジャッジ時間 | 2,916 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 | 
ソースコード
#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;
}
            
            
            
        