fork(1) download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. using namespace std;
  4. using namespace __gnu_pbds;
  5. // Policy based data structure
  6. template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  7. #define ll long long int
  8. #define pii pair<ll,ll>
  9. #define rep(i,st,en) for(ll i=st;i<en;i++)
  10. #define vi vector<ll>
  11. #define vii vector<pii>
  12. #define all(x) x.begin(),x.end()
  13. #define rall(x) x.rbegin(),x.rend()
  14. #define eb emplace_back
  15. #define yes cout<<"YES"<<endl; return;
  16. #define no cout<<"NO"<<endl; return;
  17. #define flus fflush(stdout);
  18. #define gin(x) cerr<<#x<<" : "<<x<<" ";
  19. #define fin cerr<<endl;
  20. #define F first
  21. #define S second
  22. #define np next_permutation
  23. #define inf 1e18
  24. #define mod 1000000007
  25. #define N 200009
  26. #define PI 3.14159265358979323846
  27. #define minpq priority_queue <ll, vector<ll>, greater<ll>>
  28. #define maxpq priority_queue<ll>
  29. void sout(){
  30. cout<<endl;
  31. }
  32. template <typename T,typename... Types>
  33. void sout(T var1,Types... var2){
  34. cout<<var1<<" ";
  35. sout(var2...);
  36. }
  37.  
  38.  
  39.  
  40.  
  41. void solve(){
  42.  
  43. }
  44.  
  45. int main(){
  46. #ifndef ONLINE_JUDGE
  47. freopen("input.txt", "r", stdin);
  48. freopen("output.txt", "w", stdout);
  49. #endif // ONLINE_JUDGE
  50.  
  51. ios_base::sync_with_stdio(false);
  52. cin.tie(NULL);
  53. clock_t t1=clock();
  54. int t;
  55. cin>>t;
  56. while(t--){
  57. int n;
  58. cin>>n;
  59. int ar[n];
  60. for(int i=0;i<n;i++) cin>>ar[i];
  61.  
  62. for(int i=0;i<n;i++)
  63. {
  64. int count=0;
  65. for(int j=0;j<n;j++)
  66. if(ar[i]==ar[j])count++;
  67. cout<<count<<" ";
  68. if(count==1){
  69. cout<<i+1;
  70. break;
  71. }
  72. }
  73. cout<<endl;
  74. }
  75. cerr<<"Time elapsed: "<<(double)(clock()-t1)/1000<<" s"<<endl;
  76. }
  77.  
  78.  
  79.  
Success #stdin #stdout #stderr 0.01s 5360KB
stdin
4
4
11 13 11 11
5
1 4 4 4 4
10
3 3 3 3 10 3 3 3 3 3
3
20 20 10
stdout
3 1 2
1 1
9 9 9 9 1 5
2 2 1 3
stderr
Time elapsed: 0.044 s