# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545139 | 2022-04-03T16:24:09 Z | rainboy | Board (CEOI13_board) | C | 4 ms | 1072 KB |
#include <stdio.h> #include <string.h> #define N 100000 int abs_(int a) { return a > 0 ? a : -a; } int main() { static char aa[N + 1], bb[N + 1]; static int aa_[N + 1], bb_[N + 1]; int n, m, n_, m_, h, i, j, d; scanf("%s%s", aa, bb), n = strlen(aa), m = strlen(bb); n_ = 0; for (i = 0; i < n; i++) if (aa[i] == '1') aa_[n_++] = 0; else if (aa[i] == '2') aa_[n_++] = 1; else if (aa[i] == 'U') { if (--n_) aa_[n_ - 1] += (aa_[n_] > 0 ? aa_[n_] / 2 : -(-aa_[n_] + 1) / 2); } else if (aa[i] == 'L') aa_[n_ - 1]--; else aa_[n_ - 1]++; for (i = n_ - 1; i > 0; i--) { aa_[i - 1] += (aa_[i] > 0 ? aa_[i] / 2 : -(-aa_[i] + 1) / 2); aa_[i] = (aa_[i] % 2 + 2) % 2; } m_ = 0; for (j = 0; j < m; j++) if (bb[j] == '1') bb_[m_++] = 0; else if (bb[j] == '2') bb_[m_++] = 1; else if (bb[j] == 'U') { if (--m_) bb_[m_ - 1] += (bb_[m_] > 0 ? bb_[m_] / 2 : -(-bb_[m_] + 1) / 2); } else if (bb[j] == 'L') bb_[m_ - 1]--; else bb_[m_ - 1]++; for (j = m_ - 1; j > 0; j--) { bb_[j - 1] += (bb_[j] > 0 ? bb_[j] / 2 : -(-bb_[j] + 1) / 2); bb_[j] = (bb_[j] % 2 + 2) % 2; } d = 0; for (h = 0; h < n_ && h < m_; h++) { int d_ = d * 2 + aa_[h] - bb_[h]; if (abs_(d_) > 3) break; d = d_; } printf("%d\n", n_ + m_ - h * 2 + abs_(d)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 468 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 2 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 300 KB | Output is correct |
2 | Correct | 3 ms | 596 KB | Output is correct |
3 | Correct | 1 ms | 468 KB | Output is correct |
4 | Correct | 0 ms | 296 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 292 KB | Output is correct |
3 | Correct | 1 ms | 216 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 300 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 432 KB | Output is correct |
2 | Correct | 4 ms | 588 KB | Output is correct |
3 | Correct | 2 ms | 428 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 944 KB | Output is correct |
2 | Correct | 3 ms | 944 KB | Output is correct |
3 | Correct | 1 ms | 308 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 984 KB | Output is correct |
2 | Correct | 2 ms | 980 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 3 ms | 1072 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 980 KB | Output is correct |
2 | Correct | 3 ms | 980 KB | Output is correct |
3 | Correct | 2 ms | 924 KB | Output is correct |
4 | Correct | 1 ms | 428 KB | Output is correct |
5 | Correct | 1 ms | 428 KB | Output is correct |
6 | Correct | 2 ms | 980 KB | Output is correct |