2016 Multi-University Training Contest 3题解报告

此文章可以使用目录功能哟↑(点击上方[+])

多校已经过了三场,但感觉自己总是不在状态,表现得都不是很满意,前方路漫漫...

2016 Multi-University Training Contest 3官方题解

链接→2016 Multi-University Training Contest 3

 Problem 1001 Sqrt Bo

Accept: 0    Submit: 0
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit : 131072/131072K (Java/Others)

 Problem Description

Let's define the function .

Bo wanted to know the minimum number y which satisfies .

note:,

It is a pity that Bo can only use 1 unit of time to calculate this function each time.

And Bo is impatient, he cannot stand waiting for longer than 5 units of time.

So Bo wants to know if he can solve this problem in 5 units of time.

 Input

This problem has multi test cases(no more than 120).

Each test case contains a non-negative integer n(n<10^100).


 Output

For each test case print a integer - the answer y or a string "TAT" - Bo can't solve this problem.

 Sample Input

233
233333333333333333333333333333333333333333333333333333333

 Sample Output

3
TAT

 Problem Idea

解题思路:

【题意】
给你一个整数n,问你需要经过几次
(开根号并向下取整)的操作,值为1,超过5次输出"TAT"


【类型】
技巧暴力

【分析】
由于n的大小最大可以达到10^100

故,如果直接暴力的话,还涉及到大数,肯定不现实

然后题目有了5次操作的限定,所以临界点必须是要找到的

要做到5次操作之后不为1,那最少为2,所以临界点就是


因为要达不到2,所以还要再减去1,故为


凡是大于4294967295的数均输出"TAT"即可

另外,为了避免大数比较,我们首先过滤掉输入字符串长度超过10的

最后就是特判n=0的情况,这种是无论如何达不到1的,故也是"TAT"

【时间复杂度&&优化】
O(loglogn)

题目链接→HDU 5752 Sqrt Bo

 Source Code

/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define eps 1e-8
#define LL long long
#define bitnum(a) __builtin_popcount(a)
using namespace std;
const int N = 10005;
const int M = 100005;
const int inf = 1000000007;
const int mod = 1000000007;
char s[N];
int main()
{
    __int64 n;
    int i,k;
    while(~scanf("%s",s))
    {
        k=0;
        if(strlen(s)>10)
        {
            puts("TAT");
            continue;
        }
        for(n=0,i=0;s[i]!='\0';i++)
            n=n*10+s[i]-'0';
        if(n>4294967295)
        {
            puts("TAT");
            continue;
        }
        if(!n)
        {
            puts("TAT");
            continue;
        }
        while(n!=1)
        {
            n=(__int64)sqrt(n);
            k++;
        }
        printf("%d\n",k);
    }
    return 0;
}

 Problem 1002 Permutation Bo

Accept: 0    Submit: 0
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit : 131072/131072K (Java/Others)

Special Judge

 Problem Description

There are two sequences and . is a permutation of 1∼n. particularly, .

We define the expression [condition] is 1 when condition is True,is 0 when condition is False.

Define the function

Bo have gotten the value of , and he wants to know the expected value of f(h).


 Input

This problem has multi test cases(no more than 12).

For each test case, the first line contains a non-negative integer n(1≤n≤1000), second line contains n non-negative integer ci(0≤ci≤1000).


 Output

For each test cases print a decimal - the expectation of f(h).

If the absolute error between your answer and the standard answer is no more than 10^(−4), your solution will be accepted.

 Sample Input

4
3 2 4 5
5
3 5 99 32 12

 Sample Output

6.000000
52.833333

 Problem Idea

解题思路:

【题意】
给你一个序列,求函数的期望值


【类型】
规律

【分析】
首先是题目定义的[condition]运算,当condition为真,则[condition]的值为1,否则为0

然后由于是1~n的全排列

故,当n一定时,[condition]运算的结果就已经固定了,与序列无关

也就是说,ci对f(h)的贡献取决于[condition]运算的hi,那问题就转化成了求ci在f(h)中计算了几次

那我们必须对全排列进行一次研究

这点,我们可以暴力枚举一下n=1,2,3,4,5,6,7,8,9,……的情况

暴力枚举代码如下:

/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
#define LL long long
#define bitnum(a) __builtin_popcount(a)
using namespace std;
const int N = 100005;
const int M = 32000;
const int inf = 1000000007;
const int mod = 1000000007;
int ans[N],h[N];
int main()
{
    int n,i;
    while(~scanf("%d",&n))
    {
        memset(ans,0,sizeof(ans));
        h[0]=h[n+1]=0;
        for(i=1;i<=n;i++)
            h[i]=i;
        do
        {
            for(i=1;i<=n;i++)
                if(h[i]>h[i-1]&&h[i]>h[i+1])
                    ans[i]++;
        }while(next_permutation(h+1,h+1+n));
        for(i=1;i<=n;i++)
            printf("%d ",ans[i]);
        puts("");
    }
    return 0;
}

由此,我们可以得到在求解f(h)时ci(1<=i<=n)被使用的次数

n=1   1

n=2   1 1

n=3   3 2 3

n=4   12 8 8 12

n=5   60 40 40 40 60

n=6   360 240 240 240 240 360

n=7   2520 1680 1680 1680 1680 1680 2520

n=8   20160 13440 13440 13440 13440 13440 13440 20160

n=9   181440 120960 120960 120960 120960 120960 120960 120960 181440

……

由此可知,当n为1000时,ci被使用的次数会很大很大

所以,因为是求期望,显然在这里要提前除以的排列数,即n!

这是,观察上述求得的贡献值,我们发现,当n=i时,c1的贡献为(i!)/2,那么,除去分母n!之后,就可以得到一个很简洁的规律

即,c1和cn对f(h)的期望值贡献为1/2,c2~c(n-1)对f(h)的期望值贡献为1/3

至此,可得题目所要求解的期望值

【时间复杂度&&优化】
O(n)

题目链接→HDU 5753 Permutation Bo

 Source Code

/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define eps 1e-8
#define LL long long
#define bitnum(a) __builtin_popcount(a)
using namespace std;
const int N = 1005;
const int M = 100005;
const int inf = 1000000007;
const int mod = 1000000007;
int s[N];
int main()
{
    int n,i,sum1,sum2;
    while(~scanf("%d",&n))
    {
        sum2=0;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&s[i]);
            if(i>1&&i<n)
                sum2+=s[i];
        }
        sum1=s[1]+s[n];
        printf("%.6f\n",1.0*sum1/2+1.0*sum2/3);
    }
    return 0;
}


 Problem 1003 Life Winner Bo

Accept: 0    Submit: 0
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit : 131072/131072K (Java/Others)

 Problem Description

Bo is a "Life Winner".He likes playing chessboard games with his girlfriend G.

The size of the chessboard is N×M.The top left corner is numbered(1,1) and the lower right corner is numberd (N,M).

For each game,Bo and G take turns moving a chesspiece(Bo first).At first,the chesspiece is located at (1,1).And the winner is the person who first moves the chesspiece to (N,M).At one point,if the chess can't be moved and it isn't located at (N,M),they end in a draw.

In general,the chesspiece can only be moved right or down.Formally,suppose it is located at (x,y),it can be moved to the next point (x′,y′) only if x′≥x and y′≥y.Also it can't be moved to the outside of chessboard.

Besides,There are four kinds of chess(They have movement rules respectively).

1.king.

2.rook(castle).

3.knight.

4.queen.

(The movement rule is as same as the chess.)

For each type of chess,you should find out that who will win the game if they both play in an optimal strategy.

Print the winner's name("B" or "G") or "D" if nobody wins the game.

 Input

In the first line,there is a number T as a case number.

In the next T lines,there are three numbers type,N and M.

"type" means the kind of the chess.

T≤1000,2≤N,M≤1000,1≤type≤4


 Output

For each question,print the answer.

 Sample Input

4
1 5 5
2 5 5
3 5 5
4 5 5

 Sample Output

G
G
D
B

 Problem Idea

解题思路:

【题意】
Bo和他的女朋友G博弈,Bo先手

博弈规则:棋子初始在(1,1)位置,俩人轮流移动棋子(棋子有四类,移动规则均不相同),谁先移动到(N,M)为胜,若俩人均无法移动到(N,M)为平局

另外,棋子必须往右或往下移动


【类型】
博弈(打表找规律 or 直接打表)

【分析】
首先,从(1,1)移动到(n,m)可以转换成从(n,m)移动到(1,1),这两者等价

其次,我们依次来判断每种棋子的胜负情况(根据两则定理:"能到必败态的点为必胜态"、"只能到必胜态的点为必败态")

①王(王每次能够向右or向下or向右下移动一格)

即当前位置为(x,y)时,可以移动到(x-1,y)或者(x,y-1)或者(x-1,y-1)

然后根据定理打表

const int N = 105;
int ans[N][N];
int dfs(int x,int y)
{
    if(x==1&&y==1)
        return ans[x][y]=0;
    if(x>1&&!ans[x-1][y])
        return ans[x][y]=1;
    if(y>1&&!ans[x][y-1])
        return ans[x][y]=1;
    if(x>1&&y>1&&!ans[x-1][y-1])
        return ans[x][y]=1;
    return ans[x][y]=0;
}
void table()
{
    for(int i=1;i<=20;i++)
    {
        for(int j=1;j<=20;j++)
            printf("%d ",dfs(i,j));
        puts("");
    }
}
int main()
{
    table();
    return 0;
}

打好的表如下(0表示必败,1表示必胜):

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

由表可知,当n为偶数或者m为偶数时,先手必胜,即"B";否则,则"G"

②車(可向右or向下移动任意格)

車的走法是最简单的,只要n==m,则后手胜;否则,先手胜

(因为先手只能向下或者向右走一段路;无论他往哪里走,后手往另一维走相同的步数,依然保持这一样一种状态。)

③马("日"字型移动)


即(x,y)->(x-1,y-2) or (x,y)->(x-2,y-1)

继续打表

const int N = 105;
int ans[N][N];
int dfs(int x,int y)
{
    int k=0;
    if(x==1&&y==1)
        return ans[x][y]=0;
    if(x>1&&y>2)
        if(!ans[x-1][y-2])
            return ans[x][y]=1;
        else if(ans[x-1][y-2]==1)
            k++;
    if(x>2&&y>1)
        if(!ans[x-2][y-1])
            return ans[x][y]=1;
        else if(ans[x-2][y-1]==1)
            k++;
    if(k==2)
        return ans[x][y]=0;
    return ans[x][y]=-1;
}
void table()
{
    for(int i=1;i<=20;i++)
    {
        for(int j=1;j<=20;j++)
            printf("%2d ",dfs(i,j));
        puts("");
    }
}
int main()
{
    table();
    return 0;
}

可得表如下(-1表示平局,1表示必胜,0表示必败):

 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1  0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1  0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1  0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  0 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  0 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  0 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

由表可知

if(m>n)
    swap(m,n);
k=m/3;m-=3*k;n-=3*k;
if(n==m&&n==1)
    puts("G");
else if(n==3&&m==2)
    puts("B");
else
    puts("D");
④皇后(可向右or向下or向右下移动任意格)

稍微接触过博弈的应该知道有那么一类博弈(威佐夫博弈)

"有两堆石子,俩人轮流取,每次可从其中一堆取任意颗,或从两堆取相同颗,取完胜"

是不是觉得是一样的,那问题就简单了,威佐夫博弈中,有奇异局势(必败点)

我们只要判断当前是否处在必败点即可

威佐夫博弈中,奇异局势(必败) (ak,bk):ak=[k*(1+√5)/2](取整),bk=ak+k

代入判断即可,需要注意的是取石子是取光,而我们是要走到(1,1).所以,此题的n,m要先分别减去1

【时间复杂度&&优化】
O(T)

题目链接→HDU 5754 Life Winner Bo

 Source Code

/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
#define LL long long
#define bitnum(a) __builtin_popcount(a)
using namespace std;
const int N = 100005;
const int M = 32000;
const int inf = 1000000007;
const int mod = 1000000007;
int main()
{
    int t,type,n,m,k;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d",&type,&n,&m);
        if(type==1)
            printf("%s\n",n%2&&m%2?"G":"B");
        else if(type==2)
            printf("%s\n",n!=m?"B":"G");
        else if(type==4)
        {
            if(m>n)
                swap(m,n);
            printf("%s\n",m-1==int((n-m)*1.0*(1+sqrt(5.0))/2)?"G":"B");
        }
        else
        {
            if(m>n)
                swap(m,n);
            k=m/3;m-=3*k;n-=3*k;
            if(n==m&&n==1)
                puts("G");
            else if(n==3&&m==2)
                puts("B");
            else
                puts("D");
        }
    }
    return 0;
}

 Problem 1010 Rower Bo

Accept: 0    Submit: 0
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit : 131072/131072K (Java/Others)

Special Judge

 Problem Description

There is a river on the Cartesian coordinate system,the river is flowing along the x-axis direction.

Rower Bo is placed at (0,a) at first.He wants to get to origin (0,0) by boat.Boat speed relative to water is v1,and the speed of the water flow is v2.He will adjust the direction of v1 to origin all the time.

Your task is to calculate how much time he will use to get to origin.Your answer should be rounded to four decimal places.

If he can't arrive origin anyway,print"Infinity"(without quotation marks).

 Input

There are several test cases. (no more than 1000)

For each test case,there is only one line containing three integers a,v1,v2.

0≤a≤100, 0≤v1,v2,≤100, a,v1,v2 are integers


 Output

For each test case,print a string or a real number.

If the absolute error between your answer and the standard answer is no more than 10^(−4), your solution will be accepted.

 Sample Input

2 3 3
2 4 3

 Sample Output

Infinity
1.1428571429

 Problem Idea

解题思路:

【题意】
起点(0,a),终点(0,0),水流的方向为x轴正方向,流速v2;船在静水中的速度为v1,船头始终朝向终点方向

问船多少时间能够到达点(0,0),若无法到达,输出"Infinity"


【类型】
微积分物理题 or 猜测+瞎搞

【分析】
大牛们的世界,我是无法体会的了,TAT

有一大部分人是根据第二组样例,猜测出T=(a*v1)/(v1*v1-v2*v2)

好吧,大写的"服气"

首先这个题微分方程强解显然是可以的,但是可以发现如果设参比较巧妙就能得到很方便的做法。
先分解v1,


设船到原点的距离是r,容易列出方程


上下界都是清晰的,定积分一下:


直接把第一个式子代到第二个里面


这样就解完了,另外只需要特判一下两种情况就可以了

①a=0时,此时,我们已经在终点了,速度神马的与我们无关,T=0

②v2>=v1时,糟糕,水流太快,我们干不过,好了,认输,时间"Infinity"

【时间复杂度&&优化】
O(1)

题目链接→HDU 5761 Rower Bo

 Source Code

/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define eps 1e-8
#define LL long long
#define bitnum(a) __builtin_popcount(a)
using namespace std;
const int N = 105;
const int M = 100005;
const int inf = 1000000007;
const int mod = 1000000007;
int main()
{
    int a,v1,v2;
    while(~scanf("%d%d%d",&a,&v1,&v2))
    {
        if(!a)
        {
            puts("0");
            continue;
        }
        if(v1<=v2)
        {
            puts("Infinity");
            continue;
        }
        printf("%.10f\n",1.0*a*v1/(v1*v1-v2*v2));
    }
    return 0;
}

 Problem 1011 Teacher Bo

Accept: 0    Submit: 0
Time Limit: 4000/2000 MS (Java/Others)    Memory Limit : 131072/131072K (Java/Others)

 Problem Description

Teacher BoBo is a geography teacher in the school.One day in his class,he marked N points in the map,the i-th point is at (Xi,Yi).He wonders,whether there is a tetrad (A,B,C,D)(A<B,C<D,A≠C or B≠D) such that the manhattan distance between A and B is equal to the manhattan distance between C and D.

If there exists such tetrad,print "YES",else print "NO".

 Input

First line, an integer T. There are T test cases.(T≤50)

In each test case,the first line contains two intergers, N, M, means the number of points and the range of the coordinates.(N,M≤10^5).

Next N lines, the i-th line shows the coordinate of the i-th point.(Xi,Yi)(0≤Xi,Yi≤M).


 Output

T lines, each line is "YES" or "NO".

 Sample Input

2
3 10
1 1
2 2
3 3
4 10
8 8
2 3
3 3
4 4

 Sample Output

YES
NO

 Problem Idea

解题思路:

【题意】
给你n个点,从中取3~4个点组成四元组(A,B,C,D)(A≠C or B≠D),使得A和B的曼哈顿距离等于C和D的曼哈顿距离,问是否存在这样的四元组


【类型】
暴力

【分析】
其实一开始被数据范围给蒙骗了

10^5

那暴力解是O(n^2),已经超时了,所以就各种想优化

结果以失败告终

最后暴力一发,AC,傻掉了,竟然这么水

好吧,其实无形当中已经不是O(n^2)了

暴力枚举两点a(x1,y1),b(x2,y2),求出它们的曼哈顿距离|x1-x2|+|y1-y2|,并保存

当一个曼哈顿距离两次被访问,则存在符合题意的四元组

现在,我们来讲解一下,为什么时间复杂度不是O(n^2)

很简单,题目规定了坐标的范围0~M

而M最大为10^5

假设一开始我计算出来的曼哈顿距离均不相同,那顶多只有2*10^5种可能,当执行第2*10^5+1次操作时,求得的曼哈顿距离必定是前2*10^5计算中的一种,这个应该能理解吧,鸽巢原理,或者说,抽屉原理,或许这个别名更能理解

不得不说,此题数据范围迷惑能力挺强


【时间复杂度&&优化】
O(min{n^2,m})

题目链接→HDU 5762 Teacher Bo

 Source Code

/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
#define LL long long
#define bitnum(a) __builtin_popcount(a)
using namespace std;
const int N = 100005;
const int M = 32000;
const int inf = 1000000007;
const int mod = 1000000007;
int x[N],y[N];
bool v[2*N];
int main()
{
    int t,n,m,i,j,d;
    bool flag;
    scanf("%d",&t);
    while(t--)
    {
        flag=false;
        memset(v,false,sizeof(v));
        scanf("%d%d",&n,&m);
        for(i=0;i<n;i++)
            scanf("%d%d",&x[i],&y[i]);
        for(i=0;i<n&&!flag;i++)
            for(j=i+1;j<n&&!flag;j++)
            {
                d=abs(x[i]-x[j])+abs(y[i]-y[j]);
                if(v[d])
                    flag=true;
                v[d]=true;
            }
        if(flag)
            puts("YES");
        else
            puts("NO");
    }
    return 0;
}

菜鸟成长记

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值