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了,求指正

Posted by speedcell4 at 2011-02-09 14:51:10 on Problem 3041
#include<stdio.h>
int a[501][501]={0},n,k,x,y,all;
void max(int a[501][501],int n,int *x,int *y)
{
    *x=0,*y=0;
    for(int i=1;n+1-i;i++) if(a[i][0]>a[(*x)][(*y)]) {(*x)=i;(*y)=0;}
    for(int i=1;n+1-i;i++) if(a[0][i]>a[(*x)][(*y)]) {(*x)=0;(*y)=i;}
    printf("%d  %d\n",*x,*y);
}
void kan(int a[501][501],int n,int r,int c)
{
    if(r!=0&&c==0)
    {
        a[r][c]=0;
        for(int i=1;n+1-i;i++)
        if(a[r][i]==1)
        {
            a[0][i]--;
            a[r][i]=0;
        }
    }
    if(r==0&&c!=0)
    {
        a[r][c]=0;
        for(int i=1;n+1-i;i++)
        if(a[i][c]==1)
        {
            a[i][0]--;
            a[i][c]=0;
        }
    }
}
int main()
{
    scanf("%d %d",&n,&k);
    while(k--)
    {
        scanf("%d %d",&x,&y);
        a[x][y]=1;
        a[x][0]++;
        a[0][y]++;
    }
    x=1,y=1,all=0;
    while(x||y)
    {
        max(a,n,&x,&y);
        kan(a,n,x,y);
        all++;
    }
    printf("%d\n",all-1);
}

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