657 - The die is cast

All about problems in Volume 6. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

SyFyKid
New poster
Posts: 26
Joined: Tue May 08, 2012 9:47 am

Re: 657 - The die is cast

Post by SyFyKid » Tue Jun 05, 2012 6:31 pm

Hai!
Thanks for reply.

When I send my code, I change

Code: Select all

System.getProperty("ONLINE_JUDGE") != null);
to

Code: Select all

console(true);//System.getProperty("ONLINE_JUDGE") != null);
and it uses console... so its not a problem.
brianfry713 wrote:
SyFyKid wrote:I am getting crazy solving this problem... :evil:
Don't read and write to a file.
rewrote my code again... checked again all forum inputs and still get WA :lol:
dont even know what to try...

Code: Select all

AC
got AC... :evil:

coder.tanvir
New poster
Posts: 11
Joined: Mon Mar 09, 2015 10:30 am

Re: 657 - The die is cast

Post by coder.tanvir » Tue Aug 11, 2015 12:21 am

Code: Select all

#include <bits/stdc++.h>
using namespace std;
char Grid[1000][1000];
int ans[100000];
int n , m  , ANS;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,-1,1,1,-1,-1,1};
bool Check(int i ,int j){
    for(int a =0; a<4 ; a++){
        if(Grid[i+dx[a]][j+dy[a]]=='_') return false;
    }
    return true;
}
void DFS(int  i , int j){
    if(Grid[i][j]=='X'){
        if(Check(i,j)) ANS++;
        Grid[i][j]='_';
    }
    else if(Grid[i][j]=='*') Grid[i][j]='.';
    for(int a =0 ; a< 4 ; a++){
        int x = i+dx[a];
        int y = j+dy[a];
        if(x>=0 && x<n && y>=0 && y<m && (Grid[x][y]=='*' || Grid[x][y]=='X') ) DFS(x,y);

    }

}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int x=0;
    while(cin>>m>>n && n+m){
        int p=0;
        for(int i  =0 ; i < n ; i++) cin>>Grid[i];
        for(int i =0 ; i < n ; i++)
            for(int j=0 ;j < m ;j++)
                if(Grid[i][j]=='*' || Grid[i][j]=='X'){
                        ANS=0;
                        DFS(i,j);
                        ans[p++]=ANS;
                }
      //  for(int i =0 ; i < n ; i++) cout<<Grid[i]<<endl;
         sort(ans,ans+p);
         printf("Throw %d\n",++x);
         int i;
        for( i =0 ; i < p -1 ; i++) cout<<ans[i]<<" ";
        cout<<ans[i]<<'\n';
        cout<<'\n';

    }
    return 0;

}

why wa

Post Reply

Return to “Volume 6 (600-699)”