# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
659956 | 2022-11-20T03:33:31 Z | RambaXGorilla | 게임판 (CEOI13_board) | C++17 | 15 ms | 736 KB |
#include<cstdio> #include<algorithm> #include<string> using namespace std; string pos[2] = {"0", "0"}; string sub[2] = {"0", "0"}; void inc(string &a){ for(int i = a.size() - 1;i > -1;i--){ if(a[i] - '0'){ a[i] = '0'; } else{ a[i] = '1'; break; } } } int main(){ for(int i = 0;i < 2;i++){ while(true){ char a; scanf("%c",&a); if(a == '1'){ pos[i].push_back('0'); sub[i].push_back('0'); } else if (a == '2'){ pos[i].push_back('1'); sub[i].push_back('0'); } else if (a == 'U'){ bool check = false; if(pos[i].back() < sub[i].back()){ check = true; } pos[i].pop_back(); sub[i].pop_back(); if(check){ inc(sub[i]); } } else if(a == 'L'){ inc(sub[i]); } else if(a == 'R'){ inc(pos[i]); } else{ break; } } } for(int i = 0;i < 2;i++){ bool borr = false; for(int j = pos[i].size() - 1;j > -1;j--){ if(pos[i][j] > sub[i][j]){ pos[i][j] -= borr; borr = false; } else if(pos[i][j] < sub[i][j]){ pos[i][j] += 1 - borr; borr = true; } else{ pos[i][j] = borr + '0'; } } } sort(pos, pos + 2); int len = min(pos[0].size(), pos[1].size()); int last = len; int add = 0; for(int i = 0;i < len;i++){ if(pos[0][i] < pos[1][i]){ last = i + 1; add = 1; break; } } for(int i = last;i < len;i++){ last = i + 1; if(pos[0][i] == pos[1][i]){ add = 2; if(last < len && pos[0][last] > pos[1][last]){ last++; add = 3; } break; } else if(pos[0][i] < pos[1][i]){ add = 3; break; } } printf("%d",pos[0].size() + pos[1].size() - last * 2 + add); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 340 KB | Output is correct |
2 | Correct | 2 ms | 212 KB | Output is correct |
3 | Correct | 9 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 212 KB | Output is correct |
2 | Correct | 13 ms | 472 KB | Output is correct |
3 | Correct | 5 ms | 296 KB | Output is correct |
4 | Correct | 0 ms | 288 KB | Output is correct |
5 | Correct | 1 ms | 288 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 340 KB | Output is correct |
2 | Correct | 14 ms | 468 KB | Output is correct |
3 | Correct | 6 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 736 KB | Output is correct |
2 | Correct | 8 ms | 644 KB | Output is correct |
3 | Correct | 1 ms | 304 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 724 KB | Output is correct |
2 | Correct | 12 ms | 664 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 15 ms | 684 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 724 KB | Output is correct |
2 | Correct | 10 ms | 724 KB | Output is correct |
3 | Correct | 7 ms | 600 KB | Output is correct |
4 | Correct | 2 ms | 304 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 9 ms | 724 KB | Output is correct |