fork download
  1. #include <vector>
  2. #include <list>
  3. #include <map>
  4. #include <set>
  5. #include <deque>
  6. #include <queue>
  7. #include <stack>
  8. #include <bitset>
  9. #include <algorithm>
  10. #include <functional>
  11. #include <numeric>
  12. #include <utility>
  13. #include <sstream>
  14. #include <iostream>
  15. #include <iomanip>
  16. #include <cstdio>
  17. #include <cmath>
  18. #include <cstdlib>
  19. #include <cctype>
  20. #include <string>
  21. #include <cstring>
  22. #include <cstdio>
  23. #include <cmath>
  24. #include <cstdlib>
  25. #include <ctime>
  26. #include <string.h>
  27. #include <fstream>
  28. #include <cassert>
  29. using namespace std;
  30.  
  31. #define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
  32. #define sz(a) int((a).size())
  33. #define rep(i, s, n) for(int i = s; i <= (n); ++i)
  34. #define rev(i, n, s) for(int i = (n); i >= s; --i)
  35. #define fore(x, a) for(auto &&x : a)
  36. typedef long long ll;
  37. const int mod = 1000000007;
  38. const int N = 100005;
  39.  
  40. map<int, int> a;
  41.  
  42. int main() {
  43. #ifdef loc
  44. if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
  45. assert(0);
  46. }
  47. freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
  48. #endif
  49. boost;
  50. int t;
  51. cin >> t;
  52. while (t-- > 0) {
  53. int n;
  54. cin >> n;
  55. a.clear();
  56. rep(i, 1, n) {
  57. int x;
  58. cin >> x;
  59. a[x]++;
  60. }
  61. int three = 0, two = 0;
  62. fore(x, a) {
  63. if (x.second >= 3) three++;
  64. if (x.second == 2) two++;
  65. }
  66. if (three || (two >= 2)) {
  67. cout << "YES";
  68. }
  69. else cout << "NO";
  70. cout << '\n';
  71. }
  72. return 0;
  73. }
Time limit exceeded #stdin #stdout 5s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty