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

Re:Why are you so diao ? 还有同构。。醉了

Posted by 5042 at 2015-08-06 14:53:19 on Problem 3349
In Reply To:Why are you so diao ? 还有同构。。醉了 Posted by:5042 at 2015-08-06 14:52:21
我二分做的但WA。。#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
#define inf 0x3f3f3f3f

using namespace std;

int a[100010],b[100010][7];
int look(int s,int e,int now,int pos)
{
    int mid;
    while(s<=e)
    {
        mid=(s+e)/2;
        if(mid==pos)
        {
            s++;
            continue;
        }
        if(now<a[mid])
        {
            e=mid-1;
        }
        else if(now>a[mid])
        {
            s=mid+1;
        }
        else if(a[mid]==now)
        {
            int o=0;
            for(int i=0;i<6;i++)
            {
                if( b[pos][i]!=b[mid][i] )
                {
                    o=1;
                    break;

                }
            }
            if(!o)
                return 1;
            else
            s++;

        }
    }
    return 0;
}
int main()
{
    int n,m,k,x,y,s,bj;
    ios::sync_with_stdio(false);
    while(cin>>n&&n)
    {
        bj=0;
        for(int i=0;i<n;i++)
        {
            s=0;
            for(int j=0;j<6;j++)
            {
                cin>>k;
                b[i][j]=k;
                s+=k;
            }
            sort(b[i],b[i]+6);
            a[i]=s;
        }
        sort(a,a+n);
        for(int i=0;i<n;i++)
        {
            int p=look(0,n-1,a[i],i);
            if(p==1)
            {
                bj=1;
                break;
            }
        }
        if(bj)
            puts("Twin snowflakes found.");
        else
            puts("No two snowflakes are alike.");
    }
    return 0;
}


//2
//1 1 1 1 1 1
//2 2 2 2 2 2
//2
//1 5 1 5 1 5
//3 3 3 3 3 3

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