結果

問題 No.392 2分木をたどれ
ユーザー newlife171128newlife171128
提出日時 2018-01-17 01:03:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 735 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 89,288 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 19:57:29
合計ジャッジ時間 2,733 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 724 ms
4,376 KB
testcase_02 AC 735 ms
4,380 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