Submission #1275815


Source Code Expand

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

struct node{
	vector<shared_ptr<node>>chs;
	char num;
	node() :chs(2) {

	}
	node(char n) :chs(2) {
		num = n;
	}
	node(char n, shared_ptr<node>&l, shared_ptr<node>&r) :chs{ l,r } {
		num = n;
	}
};
string solve(shared_ptr<node>&no, string&ast) {
	if (isdigit(no->num)) {
		return string(1,no->num);
	}
	else {
		string st;
		st += solve(no->chs[1], ast);
		st += solve(no->chs[0], ast);
		st += no->num;
		return st;
	}
}
vector<string>mp;
void dfs(shared_ptr<node>&no,int depth) {
	if (isdigit(no->num)) {
		mp[depth].push_back(no->num);
	}
	else {
		dfs(no->chs[1], depth+1);
		dfs(no->chs[0], depth+1);
		mp[depth].push_back(no->num);
	}
}

int main() {
	mp.resize(10000);
	string st; cin >> st;
	vector<node>v;
	for (int i = 0; i < st.size(); ++i) {
		if (isdigit(st[i])) {
			v.push_back(node(st[i]));
		}
		else {
			shared_ptr<node>r(make_shared<node>(v.back()));
			v.pop_back();
			shared_ptr<node>l(make_shared<node>(v.back()));
			v.pop_back();
			v.push_back(node(st[i], l, r));
		}
	}
	shared_ptr<node> ans =make_shared<node>( v[0]);
	string aans(solve(ans, st));
	
	dfs(ans,0);
	for (int i = 9999; i >= 0; --i) {
		cout << mp[i];
	}
	cout << endl;
	
	return 0;
}

Submission Info

Submission Time
Task A - 東京都
User yuma000
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1418 Byte
Status WA
Exec Time 1 ms
Memory 384 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
WA × 3
Set Name Test Cases
All 10_random_to_kyo.txt, 20_noised_tokyoto.txt, 99_teuchi.txt
Case Name Status Exec Time Memory
10_random_to_kyo.txt WA 1 ms 384 KB
20_noised_tokyoto.txt WA 1 ms 384 KB
99_teuchi.txt WA 1 ms 384 KB