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

wrong answer pls help!!!!

Posted by nasini at 2008-05-01 05:45:01 on Problem 2361
hi guys i am getting WA for this question.can any one help me out
here is my code
#include<iostream>
using namespace std;
int main(){
        int nt;
        scanf("%d",&nt);
        while(nt--){
                string s[3];int i;int j;
                for(i=0;i<3;i++)
                        cin>>s[i];
                string s1[3];
                for(i=0;i<3;i++){
                        s1[i]="";
                        for(j=0;j<3;j++)
                                s1[i]+=s[j][i];
                }
                bool flag1=0,flag2=0;
                for(i=0;i<3;i++)
                        if(s[i]=="XXX"||s1[i]=="XXX"){
                                flag1=1;
                                break;
                        }
                for(i=0;i<3;i++)
                        if(s[i]=="OOO"||s1[i]=="OOO"){
                                flag2=1;
                                break;
                        }
                if(flag1==1&&flag2==1)
                {
                        printf("no\n");
                        continue;
                }
                s1[0]="";
                s1[0]=s[0][0]+s[1][1]+s[2][2];
                s1[1]="";
                s1[1]=s[0][2]+s[1][1]+s[2][0];
                if(s1[0]=="XXX")
                        flag1=1;
                if(s1[0]=="OOO")
                        flag2=1;
                if(s1[1]=="XXX")
                        flag1=1;
                if(s1[1]=="OOO")
                        flag2=1;
                if(flag1==1&&flag2==1)
                {
                        printf("no\n");
                        continue;
                }
                int count1=0,count2=0;
                for(i=0;i<3;i++)
                        for(j=0;j<3;j++){
                                if(s[i][j]=='X')
                                        ++count1;
                                else if(s[i][j]=='O')
                                        ++count2;
                        }
                if(flag1==0&&flag2==0){
                if(!(count2==count1 or count2+1==count1)){
                        printf("no\n");
                        continue;
                }
                }
                else if(flag1==1){
                        if(count2!=count1-1){
                                printf("no\n");
                                continue;
                        }
                }
                else if(flag2==1){
                        if(count2!=count1){
                                printf("no\n");
                                continue;
                        }
                }
                printf("yes\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