标签:
http://acm.hdu.edu.cn/showproblem.php?pid=4334
二分T。。
/************************************************ * Author :Powatr * Created Time :2015-8-25 17:34:36 * File Name :B_D.cpp ************************************************/ #include <cstdio> #include <algorithm> #include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <list> #include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime> using namespace std; #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 typedef long long ll; const int MAXN = 2e2 + 10; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; ll a[6][MAXN]; ll b[MAXN*MAXN]; ll c[MAXN*MAXN]; ll d[MAXN]; int main(){ int T, n; scanf("%d", &T); while(T--){ scanf("%d", &n); for(int i = 1; i <= 5; i++) for(int j = 1; j <= n; j++) scanf("%I64d", &a[i][j]); int cout = 0; for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) b[++cout] = a[1][i] + a[2][j]; cout = 0; for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) c[++cout] = a[3][i] + a[4][j]; cout = n*n; for(int i = 1; i <= n; i++) d[i] = a[5][i]; sort(b + 1, b + cout + 1); sort(c + 1, c + cout + 1); sort(d + 1, d + n + 1); int flag = 1; for(int i = 1; i <= n && flag; i++){ int l = 1, r = cout; while(l <= cout && r >= 1){ if(b[l] + c[r] + d[i] == 0){ flag = 0; break; } while(l <= cout && r >= 1 && b[l] + c[r] + d[i] > 0){ r--; } while(l <= cout && r >= 1 && b[l] + c[r] + d[i] < 0){ l++; } } } if(flag) puts("No"); else puts("Yes"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/zero-begin/p/4758196.html