fork download
  1. // Problem: C. Spy Detected!
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. void solve()
  6. {
  7. int n;
  8. cin >> n;
  9. int a[105];
  10. for (int i = 0; i < n; i++)
  11. {
  12. cin >> a[i];
  13. }
  14. if (a[0] == a[1])
  15. {
  16. for (int i = 2; i < n; i++)
  17. {
  18. if (a[i] != a[0])
  19. {
  20. cout << i + 1;
  21. break;
  22. }
  23. }
  24. }
  25. else
  26. {
  27. if (a[0] == a[2])
  28. {
  29. cout << 2; // (1 + 1)
  30. }
  31. else
  32. {
  33. cout << 1;
  34. }
  35. }
  36. cout << '\n';
  37. }
  38. int main()
  39. {
  40. int t = 1;
  41. cin >> t;
  42. while (t--)
  43. {
  44. solve();
  45. }
  46. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
1