fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define FASTIO cin.tie(nullptr); ios::sync_with_stdio(false);
  4.  
  5. using namespace std;
  6.  
  7. int N,M;
  8.  
  9. int left_hand, right_hand;
  10.  
  11. int main() {
  12.  
  13. FASTIO;
  14.  
  15. cin >> N >> M;
  16.  
  17. int result = 0;
  18.  
  19. for (int i = 1; i <= M; i++) {
  20.  
  21. cin >> left_hand >> right_hand;
  22.  
  23. if (left_hand % (2 * M) == N % (2*M) || right_hand % (2 * M) == N % (2 * M) || right_hand == N || left_hand == N) {
  24.  
  25. result = i;
  26.  
  27. }
  28.  
  29. }
  30.  
  31. cout << result;
  32.  
  33. return 0;
  34.  
  35. }
Success #stdin #stdout 0.01s 5288KB
stdin
7 3
1 13
3 19
5 25
stdout
3