結果
| 問題 |
No.392 2分木をたどれ
|
| コンテスト | |
| ユーザー |
YoshiRyu
|
| 提出日時 | 2017-01-05 19:38:07 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 621 bytes |
| コンパイル時間 | 2,110 ms |
| コンパイル使用メモリ | 160,556 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-17 13:56:38 |
| 合計ジャッジ時間 | 1,704 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 |
コンパイルメッセージ
main.cpp: In function ‘void Slove()’:
main.cpp:6:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | #define SF(f,v) scanf(f,v)
| ~~~~~^~~~~
main.cpp:18:9: note: in expansion of macro ‘SF’
18 | SF("%d", &m);
| ^~
main.cpp:6:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | #define SF(f,v) scanf(f,v)
| ~~~~~^~~~~
main.cpp:22:17: note: in expansion of macro ‘SF’
22 | SF("%d", &A);
| ^~
ソースコード
#include "bits/stdc++.h"
// マクロ群
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(n) REP(i,n)
#define SF(f,v) scanf(f,v)
#define PF(f,v) printf(f,v)
using namespace std;
// 引き当てよう文字列
const char got[2] = { 'R', 'L' };
void Slove()
{
int m, A;
SF("%d", &m);
while ( m-- )
{
SF("%d", &A);
string ans = "";
do
{
// 偶数だったら"R" 奇数だったら"L" を回答文字列の先頭に差し込む
ans = got[ bitset<1>(A)[0] ] + ans;
// ツリー上の親を探す
--A >>= 1;
} while (A != 0);
puts(ans.c_str());
}
}
int main()
{
Slove();
return 0;
}
YoshiRyu