Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

请高手帮助看一下为什么总是time limited exceeded 啊?

Posted by weifei at 2009-11-12 12:00:13 on Problem 1028
#include <iostream>

#define MAXLENGTH 100
using namespace std;

struct BACK
{
    char URL[MAXLENGTH][75];
    int top;
};

struct FORWARD
{
    char URL[MAXLENGTH][75];
    int top;
};
int main()
{
    struct BACK back;
    struct FORWARD forward;
    back.top = MAXLENGTH;
    forward.top = MAXLENGTH;
    if (back.top != 0)
    {
        back.top = back.top - 1;
        strcpy(back.URL[back.top] , "http://www.acm.org/");
    }
    //push("http://www.acm.org/",back);
    char command[10];
    cin>>command;
    while (strcmp(command , "QIUT") != 0)
    {
        if (strcmp(command , "VISIT") == 0)
        {
            char U[75];
            cin>>U;
            back.top = back.top - 1;
            strcpy(back.URL[back.top] , U);
            //push(U,back);
            cout<<back.URL[back.top]<<endl;
        }
        else if (strcmp(command , "BACK") == 0)
        {
            if ((back.top + 1) <= (MAXLENGTH - 1))
            {
                forward.top = forward.top - 1;
                strcpy(forward.URL[forward.top] , back.URL[back.top]);
                //push(back.URL[back.top],forward);

                cout<<back.URL[back.top + 1]<<endl;

                back.top = back.top + 1;
                //pop(back);
            }
            else
            {
                cout<<"Ignored"<<endl;
            }
        }
        else if (strcmp(command , "FORWARD") == 0)
        {
            if (forward.top <= MAXLENGTH - 1)
            {
                back.top = back.top - 1;
                strcpy(back.URL[back.top] , forward.URL[forward.top]);
                //push(forward.URL[forward.top],back);

                cout<<forward.URL[forward.top]<<endl;

                forward.top = forward.top + 1;
                //pop(forward);
            }
            else
            {
                cout<<"Ignored"<<endl;
            }
        }

        cin>>command;
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator