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

想请hawk看一下,哪组测试数据有问题,谢谢啦^^

Posted by Pro_zq at 2009-08-21 16:43:34 on Problem 1970
这个是源码:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int dt[20][20];
    int textCnt;
    int i, j, k, m, n;

    char notPrint;

    scanf("%d", &textCnt);
    while(textCnt--)
    {
        //读入数据
        for(i = 1; i <= 19; ++i )
        {
            for(j = 1; j <= 19; ++j)
            {
                scanf("%d", &dt[i][j]);
            }
        }

        notPrint = 1;
        for(i = 1; i <= 19; ++i)
        {
            for(j = 1; j <= 19; ++j)
            {
                //横着找
                if(dt[i][j] && j + 4 <= 19 && !(j > 1 && dt[i][j] < 0 && dt[i][j - 1] < 0))
                {
                    for(k = 1; k <= 4; ++k)
                    {
                        if(abs(dt[i][j]) != abs(dt[i][j + k]))
                        {
                            break;
                        }
                    }

                    if(k == 5 &&
                       j + 5 <= 19 &&
                       abs(dt[i][j]) == abs(dt[i][j + 5]))
                    {
                        for(m = j + 1;
                            m <= 19 && abs(dt[i][j]) == abs(dt[i][m]); ++m)
                        {
                            dt[i][m] = -1 * abs(dt[i][m]);
                        }
                        dt[i][j] = dt[i][j + 1];
                    }
                    else if(k == 5 &&
                            (j + 5 <= 19 && abs(dt[i][j]) != abs(dt[i][j + 5]) ||
                            j + 4 == 19))
                    {
                        printf("%d\n%d %d\n", abs(dt[i][j]), i, j);
                        notPrint = 0;
                        break;
                    }
                }

                //竖着找
                if(dt[i][j] && i + 4 <= 19 && !(i > 1 && dt[i][j] < 0 && dt[i - 1][j] < 0))
                {
                    for(k = 1; k <= 4; ++k)
                    {
                        if(abs(dt[i][j]) != abs(dt[i + k][j]))
                        {
                            break;
                        }
                    }

                    if(k == 5 &&
                       i + 5 <= 19 && abs(dt[i][j]) == abs(dt[i + 5][j]))
                    {
                        for(m = i + 1; m <= 19 && abs(dt[i][j]) == abs(dt[m][j]); ++m)
                        {
                            dt[m][j] *= -1 * abs(dt[m][j]);
                        }
                        dt[i][j] = dt[i + 1][j];
                    }
                    else if(k == 5 &&
                       (i + 5 <= 19 && abs(dt[i][j]) != abs(dt[i + 5][j]) ||
                       i + 4 == 19))
                    {
                        printf("%d\n%d %d\n", abs(dt[i][j]), i, j);
                        notPrint = 0;
                        break;
                    }
                }

                //斜右下找
                if(dt[i][j] && i + 4 <= 19 && j + 4 <= 19 &&
                   !(i > 1 && j > 1 && dt[i][j] < 0 && dt[i - 1][j - 1] < 0))
                {
                    for(k = 1; k <= 4; ++k)
                    {
                        if(abs(dt[i][j]) != abs(dt[i + k][j + k]))
                        {
                            break;
                        }
                    }

                    if(k == 5 &&
                       i + 5 <= 19 && j + 5 <= 19 &&
                       abs(dt[i][j]) == abs(dt[i + 5][j + 5]))
                    {
                        for(m = i + 1, n = j + 1;
                            m <= 19 && n <= 19 && abs(dt[i][j]) == abs(dt[m][n]);
                            ++m, ++n)
                        {
                            dt[m][n] = -1 * abs(dt[m][n]);
                        }
                        dt[i][j] = dt[i + 1][j + 1];
                    }
                    else if(k == 5 &&
                       (i + 5 <= 19 && j + 5 <= 19 && abs(dt[i][j]) != abs(dt[i + 5][j + 5]) ||
                       i + 4 == 19 && j + 4 == 19))
                    {
                        printf("%d\n%d %d\n", abs(dt[i][j]), i, j);
                        notPrint = 0;
                        break;
                    }
                }

                //斜左下找
                if(dt[i][j] && i + 4 <= 19 && j - 4 >= 0 &&
                   !(i > 1 && j <= 18 && dt[i][j] < 0 && dt[i - 1][j + 1] < 0))
                {
                    for(k = 1; k <= 4; ++k)
                    {
                        if(abs(dt[i][j]) != abs(dt[i + k][j - k]))
                        {
                            break;
                        }
                    }

                    if(k == 5 &&
                       i + 5 <= 19 && j - 5 >= 0 &&
                       abs(dt[i][j]) == dt[i + 5][j - 5])
                    {
                        for(m = i + 1, n = j - 1;
                            m <= 19 && n >= 0 && abs(dt[i][j]) == abs(dt[m][n]);
                            ++m, --n)
                        {
                            dt[m][n] = -1 * abs(dt[m][n]);
                        }
                        dt[i][j] = dt[i + 1][j - 1];
                    }
                    else if(k == 5 &&
                       (i + 5 <= 19 && j - 5 >= 0 && abs(dt[i][j]) != abs(dt[i + 5][j - 5]) ||
                       i + 4 == 19 && j - 4 == 0))
                    {
                        printf("%d\n%d %d\n", abs(dt[i][j]), i + 4, j - 4);
                        notPrint = 0;
                        break;
                    }
                }
            } // end of for(j)

            if(!notPrint)
            {
                break;
            }
        } // end of for(i)

        if(notPrint)
        {
            printf("0\n");
        }
    } // end of while(textCnt--)

    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