fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define int long long
  5. #define yes cout << "YES\n";
  6. #define no cout << "NO\n";
  7.  
  8.  
  9. void FastIO(){
  10. ios_base::sync_with_stdio(false);
  11. cin.tie(nullptr);
  12. cout.tie(nullptr);
  13. }
  14.  
  15. void solve(){
  16. int n,m;
  17. cin >> n >> m;
  18.  
  19. int score = m;
  20.  
  21. int i = 0;
  22. while(n--){
  23. int a,b;
  24. cin >> a >> b;
  25.  
  26. if((a-i)%2 != b){
  27. --score;
  28. i++;
  29. }
  30. }
  31. cout << score << "\n";
  32. }
  33.  
  34. signed main(){
  35. FastIO();
  36.  
  37. int t;
  38. cin >> t;
  39.  
  40. while(t--){
  41. solve();
  42. }
  43. return 0;
  44. }
Success #stdin #stdout 0.01s 5324KB
stdin
3
2 4
2 1
4 0
2 7
1 1
4 0
4 9
1 0
2 0
6 1
9 0
stdout
2
7
6