結果

問題 No.1315 渦巻洞穴
ユーザー HaaHaa
提出日時 2020-12-12 21:08:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,921 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 171,104 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 02:29:17
合計ジャッジ時間 12,233 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,348 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,348 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 3 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 2 ms
4,348 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 2 ms
4,348 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 2 ms
4,348 KB
testcase_52 WA -
testcase_53 AC 3 ms
4,348 KB
testcase_54 WA -
testcase_55 AC 3 ms
4,348 KB
testcase_56 WA -
testcase_57 AC 2 ms
4,348 KB
testcase_58 WA -
testcase_59 AC 2 ms
4,348 KB
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 2 ms
4,348 KB
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 AC 2 ms
4,348 KB
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 2 ms
4,348 KB
testcase_70 WA -
testcase_71 WA -
testcase_72 AC 2 ms
4,348 KB
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'std::pair<int, int> point(int)':
main.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=1e18;

pair<int,int> point(int n){
    if(n==1)
        return {0,0};
    ll k;
    for(k=1;1;k+=2){
        if(k*k>n){
            k-=2;
            break;
        }
    }
    int now=k*k;
    int x=(k+1)/2, y=(k+1)/2;
    REP(i,k+1){
        y--; now++;
        if(now==n)
            return {x,y};
    }
    REP(i,k+1){
        x--; now++;
        if(now==n)
            return {x,y};
    }
    REP(i,k+1){
        y++; now++;
        if(now==n)
            return {x,y};
    }
    REP(i,k+1){
        x++; now++;
        if(now==n)
            return {x,y};
    }
}

string path(int dx, int dy){
    string ret="";
    if(dx>0){
        REP(i,dx/2)
            ret+="RRLR";
    }
    else{
        REP(i,-dx/2)
            ret+="LLRL";
    }
    if(dy>0){
        REP(i,dy/2)
            ret+="DDUD";
    }
    else{
        REP(i,-dy/2)
            ret+="UUDU";
    }
    return ret;
}

int main(){
    int s, t; cin >> s >> t;
    pair<int,int> sp=point(s), tp=point(t);
    string ans="RLR";
    sp.first++;
    int dx=tp.first-sp.first, dy=tp.second-sp.second;
    if(abs(dx)%2==0&&abs(dy)%2==0){
        ans+=path(dx,dy);
    }
    else{
        if(abs(sp.second)%2!=abs(tp.second)%2){
            ans+="RDUD";
            sp.first++;
            sp.second++; 
        }
        if(abs(sp.first)%2!=abs(tp.first)%2){
            if(abs(sp.second)%2==0){
                if(abs(sp.first)%2==0){
                    dx=-2-sp.first;
                    dy=-sp.second;
                    ans+=path(dx,dy);
                    ans+="UUR";
                    sp.first+=dx+1;
                    sp.second+=dy-2;
                }
                else{
                    dx=-1-sp.first;
                    dy=-2-sp.second;
                    ans+=path(dx,dy);
                    ans+="LDD";
                    sp.first+=dx-1;
                    sp.second+=dy+2;
                }
            }
            else{
                if(abs(sp.first)%2==0){
                    dx=-sp.first;
                    dy=-1-sp.second;
                    ans+=path(dx,dy);
                    ans+="LDD";
                    sp.first+=dx-1;
                    sp.second+=dy+2;
                }
                else{
                    dx=-1-sp.first;
                    dy=1-sp.second;
                    ans+=path(dx,dy);
                    ans+="UUR";
                    sp.first+=dx+1;
                    sp.second+=dy-2;
                }
            }
        }
        dx=tp.first-sp.first;
        dy=tp.second-sp.second;
        ans+=path(dx,dy);
    }
    cout << 0 << endl;
    cout << ans.size() << endl;
    cout << ans << endl;
    return 0;
}
0