結果
問題 | No.1315 渦巻洞穴 |
ユーザー | milanis48663220 |
提出日時 | 2020-12-12 21:19:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 4,231 bytes |
コンパイル時間 | 1,196 ms |
コンパイル使用メモリ | 110,904 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 22:18:31 |
合計ジャッジ時間 | 11,134 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | RE | - |
testcase_61 | RE | - |
testcase_62 | RE | - |
testcase_63 | RE | - |
testcase_64 | RE | - |
testcase_65 | RE | - |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | RE | - |
testcase_69 | RE | - |
testcase_70 | RE | - |
testcase_71 | RE | - |
testcase_72 | RE | - |
testcase_73 | RE | - |
testcase_74 | RE | - |
testcase_75 | AC | 2 ms
5,376 KB |
testcase_76 | AC | 2 ms
5,376 KB |
testcase_77 | RE | - |
testcase_78 | RE | - |
testcase_79 | RE | - |
testcase_80 | RE | - |
testcase_81 | RE | - |
コンパイルメッセージ
main.cpp: In function 'int to_number(point)': main.cpp:61:1: warning: no return statement in function returning non-void [-Wreturn-type] 61 | } | ^
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> #include <cassert> #include <cmath> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; struct point{ int x, y; }; const double eps = 0.01; int right_up(int k){ return (2*k-1)*(2*k-1)+(2*k); } int left_up(int k){ return (2*k)*(2*k)+1; } int left_bottom(int k){ return (2*k)*(2*k)+2*k+1; } int right_bottom(int k){ return (2*k+1)*(2*k+1); } int sqrt_int(int n){ return (int)(sqrt(n)+eps); } int to_cycle(int n){ int s = sqrt_int(n); if(s%2 == 0) s--; if(s*s == n){ return (s+1)/2-1; } return (s+3)/2-1; } point to_cood(int n){ int k = to_cycle(n); int x = -1, y = -1; if(n <= right_up(k)){ x = k, y = k-(right_up(k)-n); }else if(n <= left_up(k)){ x = -k+(left_up(k)-n), y = k; }else if(n <= left_bottom(k)){ x = -k, y = -k+(left_bottom(k)-n); }else{ x = k-(right_bottom(k)-n), y = -k; } return (point){x, y}; } int to_number(point p){ } int dist(point p1, point p2){ return abs(p1.x-p2.x)+abs(p1.y-p2.y); } int s, t; int x, y; int sx, sy, tx, ty; vector<int> vx, vy; void go_up(){ y++; vx.push_back(x); vy.push_back(y); } void go_down(){ y--; vx.push_back(x); vy.push_back(y); } void go_left(){ x--; vx.push_back(x); vy.push_back(y); } void go_right(){ x++; vx.push_back(x); vy.push_back(y); } void solve_odd(){ while(x != tx){ if(x < tx) go_right(); else go_left(); } while(y != ty){ if(y < ty) go_up(); else go_down(); } int sz = vx.size(); string ans; for(int i = 0; i < sz-1; i++){ if(i%2 == 0){ if(vx[i+1] == vx[i]+1) ans += "RLR"; if(vx[i+1] == vx[i]-1) ans += "LRL"; if(vy[i+1] == vy[i]+1) ans += "UDU"; if(vy[i+1] == vy[i]-1) ans += "DUD"; }else{ if(vx[i+1] == vx[i]+1) ans += "R"; if(vx[i+1] == vx[i]-1) ans += "L"; if(vy[i+1] == vy[i]+1) ans += "U"; if(vy[i+1] == vy[i]-1) ans += "D"; } } assert(ans.size() <= 200); cout << 0 << endl; cout << ans.size() << endl; cout << ans << endl; } void solve_even(){ int u = s^t; auto pu = to_cood(u); int ux = pu.x, uy = pu.y; while(x != ux){ if(x < ux) go_right(); else go_left(); } while(y != uy){ if(y < uy) go_up(); else go_down(); } while(x != tx){ if(x < tx) go_right(); else go_left(); } while(y != ty){ if(y < ty) go_up(); else go_down(); } int sz = vx.size(); int i = 0; string ans; for(int j = 0; j < sz-1; j++){ if(i%2 == 1){ if(vx[j+1] == vx[j]+1) ans += "RLR"; if(vx[j+1] == vx[j]-1) ans += "LRL"; if(vy[j+1] == vy[j]+1) ans += "UDU"; if(vy[j+1] == vy[j]-1) ans += "DUD"; }else{ if(vx[j+1] == vx[j]+1) ans += "R"; if(vx[j+1] == vx[j]-1) ans += "L"; if(vy[j+1] == vy[j]+1) ans += "U"; if(vy[j+1] == vy[j]-1) ans += "D"; } if(vx[j+1] != ux || vy[i+1] != uy) i++; } assert(ans.size() <= 200); cout << 0 << endl; cout << ans.size() << endl; cout << ans << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> s >> t; auto ps = to_cood(s); auto pt = to_cood(t); x = ps.x, y = ps.y; sx = ps.x, sy = ps.y; tx = pt.x, ty = pt.y; vx.push_back(sx); vy.push_back(sy); if(dist(ps, pt)%2 == 0){ solve_even(); }else{ solve_odd(); } // cout << ps.x << ' ' << ps.y << endl; // cout << pt.x << ' ' << pt.y << endl; }