fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. template<class S, class T> inline S chmin(S &a, T b){
  5. if(a>b){
  6. a=b;
  7. }
  8. return a;
  9. }
  10. #define main dummy_main
  11. int main(){
  12. return 0;
  13. }
  14. #undef main
  15. int x;
  16. int y;
  17. int xy;
  18. int arr[3][3];
  19. int dx[5] = {0, -1, 1, 0, 0};
  20. int dy[5] = {0, 0, 0, -1, 1};
  21. class Solution{
  22. public:
  23. int minFlips(vector<vector<int>>& mat){
  24. int mask;
  25. int i;
  26. int j;
  27. int si;
  28. int sj;
  29. int d;
  30. int cnt;
  31. int res = 1073709056;
  32. x = mat.size();
  33. y = mat[0].size();
  34. xy = x * y;
  35. for(mask=(0);mask<((1<<xy));mask++){
  36. cnt = 0;
  37. for(i=(0);i<(x);i++){
  38. for(j=(0);j<(y);j++){
  39. arr[i][j] = mat[i][j];
  40. }
  41. }
  42. for(i=(0);i<(x);i++){
  43. for(j=(0);j<(y);j++){
  44. if(mask & (1<<(i*y+j))){
  45. cnt++;
  46. for(d=(0);d<(5);d++){
  47. si = i + dx[d];
  48. sj = j + dy[d];
  49. if(0 <= si && si < x && 0 <= sj && sj < y){
  50. arr[si][sj] ^= 1;
  51. }
  52. }
  53. }
  54. }
  55. }
  56. for(i=(0);i<(x);i++){
  57. for(j=(0);j<(y);j++){
  58. if(arr[i][j]){
  59. goto Lj4PdHRW;
  60. }
  61. }
  62. }
  63. chmin(res, cnt);
  64. Lj4PdHRW:;
  65. }
  66. if(res==1073709056){
  67. res = -1;
  68. }
  69. return res;
  70. }
  71. }
  72. ;
  73. // cLay varsion 20191214-1
  74.  
  75. // --- original code ---
  76. // #define main dummy_main
  77. // {}
  78. // #undef main
  79. //
  80. // int x, y, xy;
  81. // int arr[3][3];
  82. // int dx[5] = {0, -1, 1, 0, 0};
  83. // int dy[5] = {0, 0, 0, -1, 1};
  84. //
  85. // class Solution {
  86. // public:
  87. // int minFlips(vector<vector<int>>& mat) {
  88. // int i, j, si, sj, d, cnt;
  89. // int res = int_inf;
  90. //
  91. // x = mat.size();
  92. // y = mat[0].size();
  93. // xy = x * y;
  94. //
  95. // rep(mask,(1<<xy)){
  96. // cnt = 0;
  97. // rep(i,x) rep(j,y) arr[i][j] = mat[i][j];
  98. // rep(i,x) rep(j,y) if(mask & (1<<(i*y+j))){
  99. // cnt++;
  100. // rep(d,5){
  101. // si = i + dx[d];
  102. // sj = j + dy[d];
  103. // if(0 <= si < x && 0 <= sj < y) arr[si][sj] ^= 1;
  104. // }
  105. // }
  106. // rep(i,x) rep(j,y) if(arr[i][j]) break_break_continue;
  107. // res <?= cnt;
  108. // }
  109. // if(res==int_inf) res = -1;
  110. // return res;
  111. // }
  112. // };
  113.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty