hiho Week 10 register

Ended

Participants:639

Verdict:Time Limit Exceeded
Score:40 / 100
Submitted:2014-09-07 11:36:03

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<string>
#include<stack>
using namespace std;
stack<char> Stack;
int findPos(char inOrder[],char c,int start,int end)
{
    for(int i=start;i<=end;++i)
    {
        if(inOrder[i]==c)
        {
            return i;
        }
    }
    return -1;
}
void reBuild(char preOrder[],char inOrder[],int pStart,int pEnd,int iStart,int iEnd)
{
    if(iStart>iEnd)
        return;
    if(iStart==iEnd)
    {
        Stack.push(inOrder[iStart]);
        return;
    }
    int position=findPos(inOrder,preOrder[pStart],iStart,iEnd);
    Stack.push(inOrder[position]);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX