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

啊,WA了3次,终于AC了

Posted by yzhw at 2009-03-11 16:50:19 on Problem 1063
Source Code

Problem: 1063  User: yzhw 
Memory: 264K  Time: 0MS 
Language: GCC  Result: Accepted 

Source Code 
# include <stdio.h>
# include <stdbool.h>
bool data[31];
int num;
int chk()
{
 int n=0,i;
 for(i=1;i<=num;i++) if(data[i]) n++;
 for(i=1;i<=n;i++)
 { 
   if(data[i]) continue;
   else
   {
    int j;
    for(j=i+2;j<=num;j+=2) 
      if(data[j]) break;
    if(j>num) return 0;
    else data[j]=0;
   }
 }
 return 1;
}
int main()
{
 int casenum,i;
 scanf("%d",&casenum);
 for(i=1;i<=casenum;i++)
 {
  int j;
  scanf("%d",&num);
  for(j=1;j<=num;j++) scanf("%d",data+j);
  if(num%2==1||chk()) printf("YES\n");
    else printf("NO\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