View Code of Problem 307

#include<stdio.h>
#include<string.h>
//typedef pedef struct animal
//{
//	int flag;
//	int x;
//	int y;
//};
int main(void)
{
    int n,k;
    scanf("%d %d",&n,&k);//N(1 <= N <= 50,000)
//	struct animal an[k];
//	int f,x,y;
    int fault=0;
    int zhen[k]={0};
    int an[k][3];
    for(int i=0;i<k;i++)
    {
        scanf("%d%d%d",&an[i][0],&an[i][1],&an[i][2]);
//		an[i].flag=f,an[i].x=x,an[i].y=y;
        if(an[i][1]>n||an[i][2]>n)
        {
            fault++;
            zhen[i]=100;
        }
        else if((an[i][1]==an[i][2])&&an[i][0]==2)
        {
            fault++;
            zhen[i]=100;
        }
        else if((an[i][1]!=an[i][2])&&an[i][0]==1)
        {
            fault++;
            zhen[i]=100;
        }
        else
        {
            for(int t=0;t<i;t++)
            {
                if(zhen[t]!=100)
                {
                    if((an[i][1]==an[t][1]&&an[i][2]==an[t][2])&&an[t][0]!=an[i][0])
                    {
                        fault++;
                        zhen[i]=100;
                    }
                    else if((an[i][1]==an[t][2]&&an[i][2]==an[t][1])&&an[t][0]==an[i][0])
                    {
                        fault++;
                        zhen[i]=100;
                    }
                }
            }
        }
    }
    printf("%d",fault);
    return 0;
}
/*
F:\temp\22492335.25865\Main.c: In function 'main':
F:\temp\22492335.25865\Main.c:17: error: variable-sized object may not be initialized
*/

Double click to view unformatted code.


Back to problem 307