제출 #545139

#제출 시각아이디문제언어결과실행 시간메모리
545139rainboy게임판 (CEOI13_board)C11
100 / 100
4 ms1072 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

board.c: In function 'main':
board.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%s%s", aa, bb), n = strlen(aa), m = strlen(bb);
      |  ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...