hdu 5762(鸽笼原理)

来源:互联网 发布:域名购买后要做什么 编辑:程序博客网 时间:2024/06/05 04:35
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;#define N 200020#define LL long longint n, x[N], y[N];bool vis[N];int m;int main() {    int cas;    scanf("%d", &cas);    while(cas--) {        scanf("%d%d", &n, &m);        for(int i = 1; i <= n; ++i) {            scanf("%d%d", &x[i], &y[i]);        }        if(n > 700) {            puts("YES");            continue;        }        memset(vis, 0, sizeof vis);        bool f = 0;        for(int i = 1; i <= n; ++i) {            for(int j = i + 1; j <= n; ++j) {                int d = abs(x[i] - x[j]) + abs(y[i] - y[j]);                if(vis[d]) {                    f = 1;                    break;                }                vis[d] = 1;            }        }        if(f) puts("YES");        else puts("NO");    }    return 0;}
0 0
原创粉丝点击