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

过是过了,附上代码

Posted by gong782008371 at 2013-05-23 22:21:25 on Problem 1068
我想一般人应该很难看懂我的思路吧
#include <iostream>
#include <cstring>
#include <cstdio>
#define mem(a) memset(a, 0, sizeof(a))
using namespace std;

int main()
{
    bool locat[41] = {0};
    int k[41] = {0},left[41] = {0};
    int stack[41];
    int cas, n, i;
    scanf("%d", &cas);
    while(cas -- )
    {
        mem(k);
        mem(left);
        mem(locat);
        scanf("%d", &n);
        int num;
        int key1 = 1,x = 1, j, key2 = 1;
        int top = 0;
        for(i = 1; i <= n; i ++)
        {
            scanf("%d", &num);
            for(j = x; j <= (num - key2 + x);j ++ )
            {
                k[j] = key1 ++;
                stack[++top] = j;
            }
            key2 = key1;
            k[j] = key2 - 1;
            left[j] = stack[top];
            top--;
            x = j + 1;
            locat[j] = true;
        }
        for(i=1;i<=n*2;i++)
        {
            if(locat[i])
            {
                printf("%d%c",k[i]-k[left[i]]+1,i==2*n?'\n':' ');
            }
        }
    }
    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