結果
問題 | No.1315 渦巻洞穴 |
ユーザー | carrot46 |
提出日時 | 2020-12-12 01:08:43 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 2,915 bytes |
コンパイル時間 | 1,660 ms |
コンパイル使用メモリ | 172,736 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-19 21:39:40 |
合計ジャッジ時間 | 4,302 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 3 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,944 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,944 KB |
testcase_23 | AC | 2 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,944 KB |
testcase_29 | AC | 2 ms
6,940 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 3 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | AC | 3 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 3 ms
6,944 KB |
testcase_36 | AC | 2 ms
6,944 KB |
testcase_37 | AC | 2 ms
6,944 KB |
testcase_38 | AC | 3 ms
6,940 KB |
testcase_39 | AC | 2 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,940 KB |
testcase_41 | AC | 3 ms
6,940 KB |
testcase_42 | AC | 2 ms
6,944 KB |
testcase_43 | AC | 3 ms
6,940 KB |
testcase_44 | AC | 3 ms
6,940 KB |
testcase_45 | AC | 2 ms
6,940 KB |
testcase_46 | AC | 3 ms
6,940 KB |
testcase_47 | AC | 3 ms
6,940 KB |
testcase_48 | AC | 3 ms
6,944 KB |
testcase_49 | AC | 3 ms
6,940 KB |
testcase_50 | AC | 3 ms
6,940 KB |
testcase_51 | AC | 3 ms
6,944 KB |
testcase_52 | AC | 2 ms
6,940 KB |
testcase_53 | AC | 2 ms
6,940 KB |
testcase_54 | AC | 3 ms
6,940 KB |
testcase_55 | AC | 2 ms
6,940 KB |
testcase_56 | AC | 3 ms
6,944 KB |
testcase_57 | AC | 3 ms
6,940 KB |
testcase_58 | AC | 3 ms
6,940 KB |
testcase_59 | AC | 2 ms
6,944 KB |
testcase_60 | AC | 3 ms
6,944 KB |
testcase_61 | AC | 3 ms
6,944 KB |
testcase_62 | AC | 3 ms
6,940 KB |
testcase_63 | AC | 2 ms
6,940 KB |
testcase_64 | AC | 2 ms
6,944 KB |
testcase_65 | AC | 3 ms
6,940 KB |
testcase_66 | AC | 2 ms
6,940 KB |
testcase_67 | AC | 2 ms
6,944 KB |
testcase_68 | AC | 2 ms
6,940 KB |
testcase_69 | AC | 2 ms
6,940 KB |
testcase_70 | AC | 2 ms
6,944 KB |
testcase_71 | AC | 2 ms
6,940 KB |
testcase_72 | AC | 2 ms
6,940 KB |
testcase_73 | AC | 2 ms
6,940 KB |
testcase_74 | AC | 2 ms
6,944 KB |
testcase_75 | AC | 1 ms
6,940 KB |
testcase_76 | AC | 2 ms
6,944 KB |
testcase_77 | AC | 2 ms
6,944 KB |
testcase_78 | AC | 2 ms
6,944 KB |
testcase_79 | AC | 2 ms
6,940 KB |
testcase_80 | AC | 2 ms
6,940 KB |
testcase_81 | AC | 2 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h> //#include <chrono> #pragma GCC optimize("O3") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() using ll = long long; using vec = vector<ll>; using mat = vector<vec>; ll N,M,H,W,Q,K,A,B; string S; using P = pair<ll, ll>; const ll INF = (1LL<<60); template<class T> bool chmin(T &a, const T &b){ if(a > b) {a = b; return true;} else return false; } template<class T> bool chmax(T &a, const T &b){ if(a < b) {a = b; return true;} else return false; } template<class T> void my_printv(std::vector<T> v,bool endline = true){ if(!v.empty()){ for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" "; std::cout<<v.back(); } if(endline) std::cout<<std::endl; } ll val(P p){ ll x = p.first, y = p.second, d = max(abs(x), abs(y)), r = d * 2 + 1, ms = r * r; if(y == - d) return ms + x - d; else if(x == -d) return ms - y - d * 3; else if(y == d) return ms - x - d * 5; else return ms + y - d * 7; } P pos(ll a){ if(a == 1) return make_pair(0, 0); ll lb = -1, ub = 100000; while(ub - lb > 1){ ll cen = (ub + lb) / 2, r = cen*2 + 1; (a <= r * r ? ub : lb) = cen; } ll r = ub * 2, r2 = ub, ms = (r + 1) * (r + 1); if((ms -= r) < a) return make_pair(-r2 + (a - ms), -r2); else if((ms -= r) < a) return make_pair(-r2, r2 - (a - ms)); else if((ms -= r) < a) return make_pair(r2 - (a - ms), r2); else return make_pair(r2, -r2 + (a - (ms - r))); } string ans = ""; ll pena; void move(P p, P q){ ll dx = q.first - p.first, dy = q.second - p.second; rep(i, dx){ ans.push_back('R'); ++p.first; pena ^= val(p); } reps(i, dy, 0){ ans.push_back('D'); --p.second; pena ^= val(p); } rep(i, dy){ ans.push_back('U'); ++p.second; pena ^= val(p); } reps(i, dx, 0){ ans.push_back('L'); --p.first; pena ^= val(p); } } int main(){ //cin.tie(nullptr); //ios::sync_with_stdio(false); /* random_device seed; mt19937 mt(seed()); uniform_int_distribution<> randAB(1, 1000000000); rep(i, 200000) { if(i%10000 == 0) cout<<i<<endl; A = randAB(mt); B = randAB(mt); while(A == B) B = randAB(mt); ans.clear(); pena = 0; } */ cin>>A>>B; P p = pos(A), q = pos(B); pena = A; move(p, q); ll tyousei = B ^pena; if(tyousei == 0){ P qnx = make_pair(q.first, q.second + 1); move(q, qnx); move(qnx, q); tyousei = B ^ pena; } move(q, pos(tyousei)); move(pos(tyousei), q); assert(pena == 0); cout<<0<<endl; cout<<ans.size()<<endl; cout<<ans<<endl; }