| ||||||||||
| 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 | |||||||||
Re:0ms飘过 模拟过程就行 附上代码和模拟出来的字符数组In Reply To:0ms飘过 模拟过程就行 附上代码和模拟出来的字符数组 Posted by:jwy1111 at 2018-08-22 23:01:01 > #include<cstdio>
> #include<iostream>
> #include<stack>
> #include<cstring>
> using namespace std;
> int a[100];
> char b[100];
> int main(){
> int t;
> cin>>t;
> while(t--){
> int n;
> cin>>n;
> for(int i=1;i<=n;i++){
> cin>>a[i];
> }
> a[0]=0;
> int tot=0;
> for(int i=1;i<=n;i++){
> for(int j=1;j<=a[i]-a[i-1];j++){
> b[++tot]='(';
> }
> tot++;
> b[tot]=')';
> }
> /* for(int i=1;i<=tot;i++){
> printf("%c ",b[i]);
> }
> printf("\n");*/ //模拟出来的字符数组
> int book[100];
> memset(book,0,sizeof(book));
> for(int i=1;i<=tot;i++){
> if(b[i]==')'){
> int m=i;
> int tot=0;
> while(b[m]!='('||book[m]){
> m--;
> if(b[m]==')')
> tot++;
> }
> book[m]=1;
> printf("%d ",i-m-tot);
> }
> }
> printf("\n");
> }
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator