| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 320657 | monus1042 | 게임판 (CEOI13_board) | C++17 | 2 ms | 876 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// NK
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define mkt make_tuple
#define all(x) x.begin(), x.end()
#define Bolivia_is_nice ios::sync_with_stdio(false), cin.tie(nullptr)
//typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> ord_set;
ll locationof(string s, ll nod, ll & lev){
for (int i=0; i<s.size(); i++){
if (s[i] == '1'){
nod = nod*2;
lev++;
}else if (s[i] == '2'){
nod = nod*2 + 1;
lev++;
}else if (s[i] == 'U'){
nod = nod / 2;
--lev;
}else if (s[i] == 'L'){
nod = nod - 1;
}else{ // R
nod = nod + 1;
}
}
return nod;
}
void solve(){
string a,b; cin>>a>>b;
ll AL = 0, BL = 0;
ll A = locationof(a, 1ll, AL), B = locationof(b, 1ll, BL);
//int MAXsteps = 50 * 2 + 2;
ll Log = 52;
if (AL < BL) swap(A, B), swap(AL, BL);
ll diff = AL - BL;
for (ll i = 0; i<diff; i++){
AL--;
A/=2LL;
}
int it = 0;
ll curr = 0, climb = 0;
ll Answer = 8e18;
while(1){
if (A == 0) break;
ll temp = diff + abs(A - B) + climb * 2LL;
Answer = min(Answer, temp);
climb++;
A = A / 2LL;
B = B / 2LL;
}
cout<<Answer<<'\n';
}
int main(){
Bolivia_is_nice;
int t = 1; //cin>>t;
while(t--)
solve();
return 0;
}
/*
~/.emacs
*/
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
