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 13110572081 at 2015-02-02 09:46:06 on Problem 2002
#include <stdio.h>
#include <string.h>

struct node
{
    int y;
    node *next;
}head[40010];

struct Zb
{
    int x;
    int y;
}ls[1010];
int num;

bool hs_sch(int x,int y)
{
    if(x < 0)
        x = -x + 20000;
    node *p = head[x].next;
    while(p)
    {
        if(p->y == y)
            return true;
        p = p->next;
    }
    return false;
}

int main()
{
    int n,x,y,cnt,sx;
    while(scanf("%d",&n),n)
    {
        num = 0;
        cnt = 0;
        memset(head,0,sizeof(head));
        for(int i = 0;i < n;i++)
        {
            scanf("%d%d",&x,&y);
            if(n < 4)
                continue;
            if(x < 0)
            {
                sx = -x + 20000;
            }
            else
                sx = x;
            node *p = &head[sx];
            while(p->next)
            {
                if(p->next->y == y)
                    break;
                p = p->next;
            }
            if(!p->next)
            {
                ls[num].x = x;
                ls[num].y = y;
                num++;
                node *r = new node;
                r->y = y;
                r->next = NULL;
                p->next = r;
            }
        }
        for(int i = 0;i < num - 1;i++)
        {
            for(int j = i + 1;j < num;j++)
            {
                int x3 = ls[i].x + ls[j].y - ls[i].y;
                int y3 = ls[i].y + ls[i].x - ls[j].x;
                int x4 = ls[j].x + ls[j].y - ls[i].y;
                int y4 = ls[j].y + ls[i].x - ls[j].x;
                if(hs_sch(x3,y3) && hs_sch(x4,y4))
                {
                    cnt++;
                }
            }
        }
        printf("%d\n",cnt / 2);
    }
    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