Guest User

1419A

a guest
Sep 19th, 2020
3,850
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. signed main() {
  5.     int T;
  6.     cin >> T;
  7.     while (T --> 0) {
  8.         int n;
  9.         string s;
  10.         cin >> n >> s;
  11.         bool odd = false, even = false;
  12.         for (int i = 1; i <= n; ++i) {
  13.             if (i % 2 == 1) {
  14.                 odd |= ((s[i - 1] - '0') % 2 == 1);
  15.             } else {
  16.                 even |= ((s[i - 1] - '0') % 2 == 0);
  17.             }
  18.         }
  19.         if (n % 2 == 1) {
  20.             cout << (odd ? 1 : 2) << '\n';
  21.         } else {
  22.             cout << (even ? 2 : 1) << '\n';
  23.         }
  24.     }
  25.     return 0;
  26. }
RAW Paste Data