結果

問題 No.392 2分木をたどれ
ユーザー newlife171128newlife171128
提出日時 2018-01-17 01:03:08
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 723 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 639 ms
使用メモリ 3,704 KB
最終ジャッジ日時 2023-01-13 12:18:47
合計ジャッジ時間 2,844 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,536 KB
testcase_01 AC 720 ms
3,560 KB
testcase_02 AC 723 ms
3,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <utility>

typedef long long ll;


using namespace std;

int main() {

	int m=0;
	cin>>m;

	queue<pair<int,string> > qu;

	pair<int,string> p(0,"");



	for(int i=0; i<m; i++){

		int target =0;
		cin>>target;

		string ans ="";
		qu.push(p);


	int k=1;
	while(!qu.empty()){

		pair<int,string> p = qu.front(); qu.pop();

		if(p.first >target){
			continue;
		}
		if(p.first==target){
			ans =p.second;
		}
		string s = p.second;

		pair<int,string>  np(p.first+k,s+"L");
		qu.push(np);

		k++;
		pair<int,string>  nnp(p.first+k,s+"R");
		qu.push(nnp);


	}

	cout<<ans<<endl;
	}


	return 0;
}
0