# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
263427 | 2020-08-13T16:55:20 Z | Sorting | 게임판 (CEOI13_board) | C++17 | 200 ms | 896 KB |
#include <bits/stdc++.h> using namespace std; string a, b; string get_path(const string &s){ string ans = ""; int n = s.size(); for(int i = 0; i < n; ++i){ if(s[i] == '1' || s[i] == '2') ans.push_back(s[i]); else{ if(s[i] == 'U') ans.pop_back(); else{ if(s[i] == 'L'){ for(int j = (int)ans.size() - 1; j >= 0; --j){ if(ans[j] == '2'){ ans[j] = '1'; for(int k = j + 1; k < (int)ans.size(); ++k) ans[k] = '2'; break; } } } else if(s[i] == 'R'){ for(int j = (int)ans.size() - 1; j >= 0; --j){ if(ans[j] == '1'){ ans[j] = '2'; for(int k = j + 1; k < (int)ans.size(); ++k) ans[k] = '1'; break; } } } } } } return ans; } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> a >> b; a = get_path(a); b = get_path(b); int cnt = (int)min(a.size(), b.size()) - 1; for(int i = 0; i < min(a.size(), b.size()); ++i){ if(a[i] != b[i]){ cnt = i - 1; break; } } //cout << "cnt: " << cnt << endl; if(min(a.size(), b.size()) == cnt + 1){ cout << a.size() + b.size() - 2 * (cnt + 1) << "\n"; return 0; } if(a[cnt + 1] == '2') swap(a, b); int x = a.size() + b.size() - 2 * (cnt + 1); int dist = 0, ans = x; for(int i = cnt + 1; i < min(a.size(), b.size()); ++i){ dist = 2 * dist - 1; if(a[i] == '1') dist++; if(b[i] == '2') dist++; if(dist >= 5) break; ans = min(ans, dist + x - 2 * (i - cnt)); } cout << ans << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 512 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 896 KB | Output is correct |
3 | Correct | 2 ms | 640 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 308 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 3 ms | 672 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1087 ms | 768 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1090 ms | 768 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1065 ms | 640 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |