# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
217744 | 2020-03-30T15:17:48 Z | alexandra_udristoiu | 게임판 (CEOI13_board) | C++14 | 15 ms | 896 KB |
#include<iostream> #include<cstring> #define DIM 100005 using namespace std; int i, sol, x, y, dist, t; int ad[DIM]; char s[DIM], p[2][DIM]; int solve(int t){ int i, niv, n; long long x, y; cin>> s + 1; n = strlen(s + 1); niv = 0; for(i = 1; i <= n; i++){ if(s[i] == '1' || s[i] == '2'){ niv++; ad[niv] = s[i] - '1'; } else{ if(s[i] == 'U'){ ad[niv - 1] += ad[niv] / 2; if(ad[niv] < 0 && ad[niv] % 2 != 0){ ad[niv - 1]--; } niv--; } else{ if(s[i] == 'R'){ ad[niv]++; } else{ ad[niv]--; } } } } for(i = niv; i >= 1; i--){ ad[i - 1] += ad[i] / 2; ad[i] %= 2; if(ad[i] == -1){ ad[i] = 1; ad[i - 1]--; } p[t][i] = ad[i] + '0'; } return niv; } int main(){ x = solve(0); y = solve(1); sol = x + y; for(i = 1; i <= min(x, y); i++){ if(p[0][i] != p[1][i]){ break; } } sol -= 2 * (i - 1); t = p[0][i] - '0'; if(i <= min(x, y) ){ sol--; } for(i = i + 1; i <= min(x, y); i++){ dist *= 2; if(p[t][i] == '0'){ dist++; } if(p[1 - t][i] == '1'){ dist++; } sol = min(sol, dist + 1 + x - i + y - i); if(dist > 200000){ break; } } cout<< sol; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 11 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 15 ms | 512 KB | Output is correct |
3 | Correct | 9 ms | 512 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 384 KB | Output is correct |
2 | Correct | 14 ms | 512 KB | Output is correct |
3 | Correct | 10 ms | 512 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 640 KB | Output is correct |
2 | Correct | 14 ms | 896 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 768 KB | Output is correct |
2 | Correct | 14 ms | 896 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 14 ms | 896 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 768 KB | Output is correct |
2 | Correct | 15 ms | 768 KB | Output is correct |
3 | Correct | 11 ms | 768 KB | Output is correct |
4 | Correct | 6 ms | 384 KB | Output is correct |
5 | Correct | 6 ms | 512 KB | Output is correct |
6 | Correct | 14 ms | 896 KB | Output is correct |