fork(1) download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include<cstdlib>
  4.  
  5. #include <string>
  6. #include <vector>
  7. #include <set>
  8. #include <map>
  9. #include <algorithm>
  10.  
  11. using namespace std;
  12.  
  13. /*
  14. #define gc getchar_unlocked //for grader
  15. #define pc putchar_unlocked //for grader
  16. //*/
  17.  
  18. //*
  19. #define gc getchar // for windows
  20. #define pc putchar // for windows
  21. //*/
  22.  
  23.  
  24. #define ll long long
  25. #define ull unsigned long long
  26. #define MOD 1000000007
  27.  
  28. #define _test() int _t;_t=get();while(_t--)
  29. #define _testll() ll lt;lt=getll();while(lt--)
  30. #define _testull() ull __t;__t=getull();while(__t--)
  31.  
  32.  
  33. #define _for(i,a,b) for(i=a;i<b;i++)
  34. #define _forr(i,a,b) for(i=a;a>b;i--)
  35. #define _fori(i,a,b,inc) for(i=a;i<b;i+=inc)
  36.  
  37. #define pb push_back
  38. #define mp make_pair
  39. #define all(v) v.begin(), v.end()
  40. #define rall(v) v.rbegin(), v.rend()
  41. #define ssort(v) sort(all(v))
  42. #define rsort(v) sort(rall(v))
  43. #define mem(list,char) memset(list, char, sizeof(a))
  44.  
  45.  
  46. typedef vector<int> VI;
  47. typedef vector<ll> VLL;
  48. typedef vector<ull> VULL;
  49.  
  50.  
  51. /* Input functions */
  52. inline int get(){int c=gc(),v=0, f=1;for(;c<'0'||c>'9';c=gc()){if(c=='-'){f=-1;c=gc();break;}}for(;c>='0' && c<='9';c=gc())v=(v<<3)+(v<<1)+c-'0';return v*f;}
  53. inline ll getll(){ll c=gc(),v=0, f=1;for(;c<'0' || c>'9';c=gc()){if(c=='-'){f=-1;c=gc();break;}}for(;c>='0' && c<='9';c=gc())v=(v<<3)+(v<<1)+c-'0';return v*f;}
  54. inline ull getull(){ull n=0,c=gc();while(c<'0'||c>'9')c=gc();while(c<='9'&&c>='0'){n=(n<<3)+(n<<1)+c-'0';c=gc();}return n;}
  55. /* End input functions */
  56.  
  57.  
  58. /* Output Functions */
  59. void out(int n){char b[10];int i=10;if(n<0){pc('-');n=-n;}do{b[--i]=(n%10)+'0';n/=10;}while(n);do{pc(b[i]);}while(++i<10);}
  60. void outn(int n){char b[10];int i=10;if(n<0){pc('-');n=-n;}do{b[--i]=(n%10)+'0';n/=10;}while(n);do{pc(b[i]);}while(++i<10);pc('\n');}
  61. void outs(int n){char b[10];int i=10;if(n<0){pc('-');n=-n;}do{b[--i]=(n%10)+'0';n/=10;}while(n);do{pc(b[i]);}while(++i<10);pc(' ');}
  62. /* End output functions */
  63.  
  64. //#define read(val) scanf("%d",&val)
  65. int main()
  66. {
  67. int t;
  68.  
  69. #ifndef ONLINE_JUDGE
  70. freopen("a.in", "r" , stdin);
  71. freopen("a.out", "w", stdout);
  72. #endif
  73.  
  74. t=get();
  75. //read(t);
  76.  
  77. while(t--)
  78. {
  79. int arr[100010]={0};
  80. int inp,i;
  81. inp=get();
  82. //read(inp);
  83. int c=0,val;
  84. _for(i,0,inp)
  85. {
  86. val=get();
  87. //read(val);
  88. arr[val]++;
  89. if(arr[val]==1)c++;
  90. }
  91. outn(c);
  92. }
  93. return 0;
  94. }
  95.  
  96.  
  97. /* Test cases are:
  98. 2
  99. 3
  100. 3 3 3
  101. 4
  102. 1 2 3 3
  103. */
  104.  
  105. // Problem is as i used ifndef it stopped working. I implemented ifndef for first time pelase guide me..
Time limit exceeded #stdin #stdout 5s 3608KB
stdin
Standard input is empty
stdout
Standard output is empty