fork download
  1. #include <vector>
  2. #include <list>
  3. #include <map>
  4. #include <set>
  5. #include <deque>
  6. #include <queue>
  7. #include <stack>
  8. #include <bitset>
  9. #include <algorithm>
  10. #include <functional>
  11. #include <numeric>
  12. #include <utility>
  13. #include <sstream>
  14. #include <iostream>
  15. #include <iomanip>
  16. #include <cstdio>
  17. #include <cmath>
  18. #include <cstdlib>
  19. #include <cctype>
  20. #include <string>
  21. #include <cstring>
  22. #include <cstdio>
  23. #include <cmath>
  24. #include <cstdlib>
  25. #include <ctime>
  26. #include <fstream>
  27. #include <cassert>
  28. using namespace std;
  29.  
  30. #define sz(a) int((a).size())
  31. #define rep(i, s, n) for(int i = s; i <= (n); ++i)
  32. #define rev(i, n, s) for(int i = (n); i >= s; --i)
  33. #define fore(x, a) for(auto &&x : a)
  34. typedef long long ll;
  35. const int mod = 1000000007;
  36. const int N = 1000005;
  37.  
  38. int a[N];
  39. int b[N];
  40. int n;
  41.  
  42. int go() {
  43. int ans = -1;
  44. rep(step, 0, 3) {
  45. rep(i, 1, n) {
  46. b[i] = a[i];
  47. }
  48. int cur = 0;
  49. if(step & 1) {
  50. cur++;
  51. b[1] ^= 1;
  52. b[2] ^= 1;
  53. }
  54. if((step / 2) & 1) {
  55. cur++;
  56. b[n] ^= 1;
  57. b[n - 1] ^= 1;
  58. }
  59. rep(i, 1, n - 2) {
  60. if(b[i]) {
  61. b[i] ^= 1;
  62. b[i + 1] ^= 1;
  63. b[i + 2] ^= 1;
  64. cur++;
  65. }
  66. }
  67. if(b[n] == 0 && (n == 1 || b[n - 1] == 0)) {
  68. if(ans == -1) {
  69. ans = cur;
  70. } else {
  71. ans = min(ans, cur);
  72. }
  73. }
  74. }
  75. return ans;
  76. }
  77.  
  78. int main() {
  79. #ifdef loc
  80. if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
  81. assert(0);
  82. }
  83. freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
  84. #endif
  85. ios_base::sync_with_stdio(0);
  86. cin.tie(0);
  87. cout.tie(0);
  88. cin >> n;
  89. rep(i, 1, n) {
  90. cin >> a[i];
  91. a[i] &= 1;
  92. }
  93. int ans1 = go();
  94. rep(i, 1, n) {
  95. a[i] ^= 1;
  96. }
  97. int ans2 = go();
  98. cout << ans2 << " " << ans1 << endl;
  99. return 0;
  100. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: illegal character: '#'
#include <vector>
^
Main.java:1: error: class, interface, or enum expected
#include <vector>
         ^
Main.java:2: error: illegal character: '#'
#include <list>
^
Main.java:3: error: illegal character: '#'
#include <map>
^
Main.java:4: error: illegal character: '#'
#include <set>
^
Main.java:5: error: illegal character: '#'
#include <deque>
^
Main.java:6: error: illegal character: '#'
#include <queue>
^
Main.java:7: error: illegal character: '#'
#include <stack>
^
Main.java:8: error: illegal character: '#'
#include <bitset>
^
Main.java:9: error: illegal character: '#'
#include <algorithm>
^
Main.java:10: error: illegal character: '#'
#include <functional>
^
Main.java:11: error: illegal character: '#'
#include <numeric>
^
Main.java:12: error: illegal character: '#'
#include <utility>
^
Main.java:13: error: illegal character: '#'
#include <sstream>
^
Main.java:14: error: illegal character: '#'
#include <iostream>
^
Main.java:15: error: illegal character: '#'
#include <iomanip>
^
Main.java:16: error: illegal character: '#'
#include <cstdio>
^
Main.java:17: error: illegal character: '#'
#include <cmath>
^
Main.java:18: error: illegal character: '#'
#include <cstdlib>
^
Main.java:19: error: illegal character: '#'
#include <cctype>
^
Main.java:20: error: illegal character: '#'
#include <string>
^
Main.java:21: error: illegal character: '#'
#include <cstring>
^
Main.java:22: error: illegal character: '#'
#include <cstdio>
^
Main.java:23: error: illegal character: '#'
#include <cmath>
^
Main.java:24: error: illegal character: '#'
#include <cstdlib>
^
Main.java:25: error: illegal character: '#'
#include <ctime>
^
Main.java:26: error: illegal character: '#'
#include <fstream>
^
Main.java:27: error: illegal character: '#'
#include <cassert>
^
Main.java:30: error: illegal character: '#'
#define sz(a) int((a).size())
^
Main.java:30: error: class, interface, or enum expected
#define sz(a) int((a).size())
        ^
Main.java:31: error: illegal character: '#'
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
^
Main.java:31: error: class, interface, or enum expected
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
                                     ^
Main.java:31: error: class, interface, or enum expected
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
                                               ^
Main.java:32: error: illegal character: '#'
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
^
Main.java:32: error: class, interface, or enum expected
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
                                       ^
Main.java:32: error: class, interface, or enum expected
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
                                               ^
Main.java:33: error: illegal character: '#'
#define fore(x, a) for(auto &&x : a)
^
Main.java:35: error: class, interface, or enum expected
const int mod = 1000000007;
^
Main.java:36: error: class, interface, or enum expected
const int N = 1000005;
^
Main.java:38: error: class, interface, or enum expected
int a[N];
^
Main.java:39: error: class, interface, or enum expected
int b[N];
^
Main.java:40: error: class, interface, or enum expected
int n;
^
Main.java:42: error: class, interface, or enum expected
int go() {
^
Main.java:44: error: class, interface, or enum expected
  rep(step, 0, 3) {
  ^
Main.java:47: error: class, interface, or enum expected
    }
    ^
Main.java:49: error: class, interface, or enum expected
    if(step & 1) {
    ^
Main.java:51: error: class, interface, or enum expected
      b[1] ^= 1;
      ^
Main.java:52: error: class, interface, or enum expected
      b[2] ^= 1;
      ^
Main.java:53: error: class, interface, or enum expected
    }
    ^
Main.java:56: error: class, interface, or enum expected
      b[n] ^= 1;
      ^
Main.java:57: error: class, interface, or enum expected
      b[n - 1] ^= 1;
      ^
Main.java:58: error: class, interface, or enum expected
    }
    ^
Main.java:62: error: class, interface, or enum expected
        b[i + 1] ^= 1;
        ^
Main.java:63: error: class, interface, or enum expected
        b[i + 2] ^= 1;
        ^
Main.java:64: error: class, interface, or enum expected
        cur++;
        ^
Main.java:65: error: class, interface, or enum expected
      }
      ^
Main.java:70: error: class, interface, or enum expected
      } else {
      ^
Main.java:72: error: class, interface, or enum expected
      }
      ^
Main.java:76: error: class, interface, or enum expected
}
^
Main.java:79: error: illegal character: '#'
#ifdef loc
^
Main.java:82: error: class, interface, or enum expected
  }
  ^
Main.java:84: error: illegal character: '#'
#endif
^
Main.java:85: error: class, interface, or enum expected
  ios_base::sync_with_stdio(0);
  ^
Main.java:86: error: class, interface, or enum expected
  cin.tie(0);
  ^
Main.java:87: error: class, interface, or enum expected
  cout.tie(0);
  ^
Main.java:88: error: class, interface, or enum expected
  cin >> n;
  ^
Main.java:89: error: class, interface, or enum expected
  rep(i, 1, n) {
  ^
Main.java:91: error: class, interface, or enum expected
    a[i] &= 1;
    ^
Main.java:92: error: class, interface, or enum expected
  }
  ^
Main.java:94: error: class, interface, or enum expected
  rep(i, 1, n) {
  ^
Main.java:96: error: class, interface, or enum expected
  }
  ^
Main.java:98: error: class, interface, or enum expected
  cout << ans2 << " " << ans1 << endl;
  ^
Main.java:99: error: class, interface, or enum expected
  return 0;
  ^
Main.java:100: error: class, interface, or enum expected
}
^
74 errors
stdout
Standard output is empty