結果
問題 |
No.392 2分木をたどれ
|
ユーザー |
![]() |
提出日時 | 2016-12-29 10:17:42 |
言語 | C90 (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 664 bytes |
コンパイル時間 | 871 ms |
コンパイル使用メモリ | 23,936 KB |
実行使用メモリ | 15,688 KB |
最終ジャッジ日時 | 2024-12-15 07:25:06 |
合計ジャッジ時間 | 7,331 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 TLE * 2 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:20:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%d", &m); | ^~~~~~~~~~~~~~~ main.c:22:19: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | rep(i, m) scanf("%d", &a[i]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <math.h> #define rep(i, n) for (i = 0; i < n; i++) #define left 0 #define right 1 int follow(int s, int r) { int i, a = s; if (r == left) a = 2 * a + 1; else if (r == right) a = 2 * a + 2; return a; } int getbit(int x, int n) { return !!(x & (int)pow(2, n - 1)); } int main() { int m; scanf("%d", &m); int a[4094], i; rep(i, m) scanf("%d", &a[i]); int j, k, l; rep(i, m) rep(l, 12) rep(j, pow(2, l)) { int t = 0, ans[11]; rep(k, l) { ans[k] = getbit(j, k + 1); t = follow(t, ans[k]); } if (t == a[i]) { rep(k, l) printf("%c", ans[k] == left ? 'L' : 'R'); printf("\n"); break; } } return 0; }