#include<iostream> #include<cstring> using namespace std; int a[10000000],b[10000000] = { 0 }; int main() { int t, n, x; cin >> t; while (t--) { //int b[10000000] = { 0 }; //memset(b, 0, sizeof(b)); cin >> n >> x; for (int i = 1; i <= n; i++) { cin >> a[i]; b[a[i]]=i; } int flag = 0; for (int i = 1; i <=n; i++) { if (b[x - a[i]] != 0&&b[x-a[i]]!=a[i]) { flag = 1; break; } } if (flag) { cout << "YES" << endl; } else cout << "NO" << endl; } return 0; } |
Double click to view unformatted code.