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

Re:汗。。。真的用队列过不了。。。栈才能过。。而且还不是返回tle。。是wa。。。

Posted by masque at 2009-07-17 20:42:11 on Problem 3159
In Reply To:汗。。。真的用队列过不了。。。栈才能过。。而且还不是返回tle。。是wa。。。 Posted by:200731000904 at 2009-04-27 18:45:57
队列也过不了,用STL的会超时,自己的就直接WA。。。不明白为什么,麻烦用队列过的朋友指点

struct queue {
    int q[QUEUE_SIZE];			//队列最大长度,外部用const int QUEUE_SIZE=XXX;
    int rear,front;

    void init(){
        rear=0;
        front=0;
    }
    bool empty() {
        return (front==rear)?1:0;
    } //反1表已空,否则未空
    void push(int n) {
        if(n==QUEUE_SIZE){
            rear=0;
        }
        q[rear]=n;
        rear++;
    }
    int pop() {
        int x;
        if(front==QUEUE_SIZE){
            front=0;
        }
        x=q[front];
        front++;
        return x;
    }
};

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