結果

問題 No.1315 渦巻洞穴
ユーザー HaaHaa
提出日時 2020-12-12 20:39:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,227 bytes
コンパイル時間 1,603 ms
コンパイル使用メモリ 170,732 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-20 02:28:40
合計ジャッジ時間 11,297 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 3 ms
4,348 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 2 ms
4,348 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 3 ms
4,348 KB
testcase_56 WA -
testcase_57 AC 3 ms
4,348 KB
testcase_58 WA -
testcase_59 AC 2 ms
4,348 KB
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
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(sp.second%2!=tp.second%2){
            ans+="RDUD";
            sp.first++;
            sp.second++; 
        }
        if(sp.first%2!=tp.first%2){
            if(sp.first%2==0){
                dx=-2-sp.first;
                dy=-sp.second;
                ans+=path(dx,dy);
                ans+="RUU";
                sp.first+=dx+1;
                sp.second+=dy-2;
            }
            else{
                dx=-1-sp.first;
                dy=-2-sp.second;
                ans+=path(dx,dy);
                ans+="DDL";
                sp.first+=dx-1;
                sp.second+=dy+2;
            }
        }
        dx=tp.first-sp.first;
        dy=tp.second-sp.second;
        ans+=ans+=path(dx,dy);
    }
    cout << 0 << endl;
    cout << ans.size() << endl;
    cout << ans << endl;
    return 0;
}
0