| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
过是过了,附上代码我想一般人应该很难看懂我的思路吧
#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator