fork(2) download
  1. /*author - Aryan Mittal*/
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. #pragma GCC push_options
  6. #pragma GCC optimize ("unroll-loops")
  7.  
  8.  
  9. #define print(a) for (auto x : a) cout << x << " "; cout << endl
  10. #define print_upto(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl
  11. #define take(x,n) for(int i=0;i<n;i++) cin>>x[i];
  12.  
  13. #define watch(x) cout << (#x) << " is " << (x) << "\n"
  14. #define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
  15.  
  16. #define ll long long
  17. #define pie_value 3.14159265358979323846
  18. #define mod (ll)1000000007
  19.  
  20. ll power(ll a, ll b) {
  21. if (b == 0)
  22. return 1;
  23.  
  24. ll val = power(a, b / 2) % mod;
  25. if (b % 2 == 0) {
  26. return (val * val) % mod;
  27. } else {
  28. return (a % mod * (val * val) % mod) % mod;
  29. }
  30. }
  31.  
  32. int main() {
  33.  
  34. // Use ctrl+shift+b ( second option )
  35. ios_base::sync_with_stdio(false);
  36. cin.tie(0);
  37. cout.tie(0);
  38.  
  39. #ifndef ONLINE_JUDGE
  40. freopen("input.txt", "r", stdin);
  41. freopen("output.txt", "w", stdout);
  42. freopen("error.txt" , "w" , stderr);
  43. #endif
  44.  
  45. ll n;
  46. cin >> n;
  47.  
  48. ll mp_oe = 0, mp_ee = 0, mp_oo = 0;
  49. ll no = n;
  50.  
  51. while (n--) {
  52. ll l, r;
  53. cin >> l >> r;
  54.  
  55. if (l % 2 == 0 && r % 2 == 0) {
  56. mp_ee++;
  57. } else if (l % 2 != 0 && r % 2 != 0) {
  58. mp_oo++;
  59. } else {
  60. mp_oe++;
  61. }
  62. }
  63.  
  64. n = no;
  65.  
  66.  
  67. if (mp_oe == 0 && mp_oo % 2 == 0) {
  68. cout << 0 << "\n";
  69. } else if (mp_oe == 0 && mp_oo % 2 != 0) {
  70. cout << power(2, n) % mod << "\n";
  71. } else {
  72. //watch(n);
  73. cout << power(2, n - 1) % mod << "\n";
  74. }
  75.  
  76.  
  77.  
  78. return 0;
  79. }
  80.  
Success #stdin #stdout 0s 4496KB
stdin
Standard input is empty
stdout
0