fork download
  1. #include<iostream>
  2. #include<unordered_map>
  3. #include<algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int t;
  9. cin>>t;
  10. while(t--)
  11. {
  12. int n;
  13. cin >>n;
  14. long long int * arr = new long long int [n];
  15.  
  16. unordered_map<long long int ,int> mymap ;
  17.  
  18. for(int i=0;i<n;i++)
  19. {
  20. cin>>arr[i];
  21. //pair<long long int ,int> p ;
  22. //p.first=arr[i];
  23. //p.second = i;
  24. //mymap.insert(p);
  25. }
  26. sort(arr,arr+n);
  27. bool flag = 0;
  28. int start = 0;
  29. int last = n-1 ;
  30. long long int searcs;
  31. while(start<last)
  32. {
  33. searcs = arr[start] * arr[last] ;
  34. if(searcs>arr[n-1])
  35. last--;
  36. else if(searcs<arr[0])
  37. start++;
  38. /*else
  39.   {
  40.   auto ans = mymap.find(searcs);
  41.   if(ans!=mymap.end())
  42.   {
  43.   flag= 1;
  44.   break;
  45.   }
  46.   }*/
  47. }
  48.  
  49. pair<long long int ,int> p ;
  50. for (int i=start;i<=last;i++){
  51. p.first=arr[i];
  52. p.second = i;
  53. mymap.insert(p);
  54. }
  55.  
  56. /*while(start<last)
  57.   {
  58.   searcs = arr[start] * arr[last] ;
  59.   if(searcs>arr[n-1])
  60.   last--;
  61.   else if(searcs<arr[0])
  62.   start++;*/
  63. //else
  64. //{
  65. auto ans = mymap.find(searcs);
  66. if(ans!=mymap.end())
  67. {
  68. flag= 1;
  69. break;
  70. }
  71. }
  72.  
  73.  
  74. if(flag)
  75. cout<<"yes"<<endl;
  76. else
  77. cout<<"no"<<endl;
  78.  
  79.  
  80. }
  81. return 0;
  82. }
  83.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/5/unordered_map:35:0,
                 from prog.cpp:2:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
prog.cpp: In function 'int main()':
prog.cpp:16:9: error: 'unordered_map' was not declared in this scope
         unordered_map<long long int ,int> mymap ;
         ^
prog.cpp:16:23: error: expected primary-expression before 'long'
         unordered_map<long long int ,int> mymap ;
                       ^
prog.cpp:53:5: error: 'mymap' was not declared in this scope
     mymap.insert(p);
     ^
prog.cpp:65:18: error: 'ans' does not name a type
             auto ans = mymap.find(searcs);
                  ^
prog.cpp:66:16: error: 'ans' was not declared in this scope
             if(ans!=mymap.end())
                ^
prog.cpp:66:21: error: 'mymap' was not declared in this scope
             if(ans!=mymap.end())
                     ^
prog.cpp:74:12: error: 'flag' was not declared in this scope
         if(flag)
            ^
prog.cpp: At global scope:
prog.cpp:81:1: error: expected unqualified-id before 'return'
 return 0;
 ^
prog.cpp:82:1: error: expected declaration before '}' token
 }
 ^
stdout
Standard output is empty