# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105466 | 2019-04-12T12:51:01 Z | alexpetrescu | 게임판 (CEOI13_board) | C++14 | 3 ms | 512 KB |
#include <cstdio> #include <cstdlib> #include <algorithm> FILE *fin = fopen("a.in", "r"), *fout = fopen("a.out", "w"); //#define fin stdin //#define fout stdout #define MAXN 100000 char s[MAXN + 10]; int n[2], a[2][MAXN]; inline void un_pas(int &poz, int &n, int v[]) { if (s[poz] == '1') v[n++] = 0; else if (s[poz] == '2') v[n++] = 1; else if (s[poz] == 'U') n--; else if (s[poz] == 'L') { int p = n - 1; while (v[p] == 0) { v[p] = 1; p--; } v[p] = 0; } else { int p = n - 1; while (v[p] == 1) { v[p] = 0; p--; } v[p] = 1; } poz++; } inline void getVal(int &n, int v[]) { fgets(s, MAXN + 5, fin); int poz = 0; while (s[poz] != '\n') un_pas(poz, n, v); for (int i = 0; i < n; i++) printf("%d ", v[i]); printf("\n"); } int main() { getVal(n[0], a[0]); getVal(n[1], a[1]); int x = 0, y = 1; if (n[x] > n[y]) std::swap(x, y); int dist = n[y] - n[x]; n[y] = n[x]; int poz = 0; while (poz < n[x] && a[0][poz] == a[1][poz]) poz++; if (poz < n[x] && a[x][poz] == 1) std::swap(x, y); dist += 2 * (n[x] - poz); int m = 0, ans = dist; for (int i = poz; m < 1000000000 && i < n[x]; i++) { dist -= 2; m *= 2; if (a[x][i] == 1 && a[y][i] == 0) m--; else if (a[x][i] == 0 && a[y][i] == 1) m++; ans = std::min(ans, dist + m); } fprintf(fout, "%d\n", ans); fclose(fin); fclose(fout); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |