Submission #3164187


Source Code Expand

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

struct four{
  int xy[4];
};

int main(){
  int H, W;
  cin >> H >> W;
  int a[H][W];
  vector<four> ans;
  REP(i, H){
    REP(j, W){
      cin >> a[i][j];
    }
  }
  four work;
  int sousa=0;

  if(H==1){
    REP(j, W-1){
      if(a[0][j]%2){
        ++sousa;
        work.xy[0]=1;
        work.xy[1]=j+1;
        work.xy[2]=1;
        work.xy[3]=j+2;
        ans.push_back(work);
        --a[0][j];
        ++a[0][j+1];
      }
    }
    goto end;
  }

  if(W==1){
    REP(i, H){
      if(a[i][0]%2){
        ++sousa;
        work.xy[0]=i+1;
        work.xy[1]=1;
        work.xy[2]=i+2;
        work.xy[3]=1;
        ans.push_back(work);
        --a[i][0];
        ++a[i+1][0];
      }
    }
    goto end;
  }

  REP(i, H){
    REP(j, W-1){
      if(a[i][j]%2){
        ++sousa;
        work.xy[0]=i+1;
        work.xy[1]=j+1;
        work.xy[2]=i+1;
        work.xy[3]=j+2;
        ans.push_back(work);
        --a[i][j];
        ++a[i][j+1];
      }
    }
  }
  REP(i, H-1){
    int j = W-1;
      if(a[i][j]%2){
        ++sousa;
        work.xy[0]=i+1;
        work.xy[1]=j+1;
        work.xy[2]=i+2;
        work.xy[3]=j+1;
        ans.push_back(work);
        --a[i][j];
        ++a[i+1][j];
      }
  }

  end:
  cout << sousa << endl;
  REP(i, ans.size()){
    REP(j, 3){
      cout << ans[i].xy[j] << " ";
    }
    cout << ans[i].xy[3];
    cout << endl;
  }



  return 0;
}

Submission Info

Submission Time
Task D - Make Them Even
User howahowa
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1673 Byte
Status AC
Exec Time 268 ms
Memory 5104 KB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 29
AC × 3
Set Name Test Cases
All hand_1, hand_2, hand_3, hand_4, hand_5, hand_6, max_1, max_10, max_2, max_3, max_4, max_5, max_6, max_7, max_8, max_9, random_1, random_10, random_2, random_3, random_4, random_5, random_6, random_7, random_8, random_9, sample_01, sample_02, sample_03
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_1 AC 1 ms 256 KB
hand_2 AC 1 ms 256 KB
hand_3 AC 2 ms 256 KB
hand_4 AC 2 ms 256 KB
hand_5 AC 263 ms 5104 KB
hand_6 AC 40 ms 1280 KB
max_1 AC 265 ms 5104 KB
max_10 AC 268 ms 5104 KB
max_2 AC 264 ms 5104 KB
max_3 AC 262 ms 5104 KB
max_4 AC 266 ms 5104 KB
max_5 AC 266 ms 5104 KB
max_6 AC 264 ms 5104 KB
max_7 AC 264 ms 5104 KB
max_8 AC 266 ms 5104 KB
max_9 AC 265 ms 5104 KB
random_1 AC 3 ms 256 KB
random_10 AC 35 ms 892 KB
random_2 AC 55 ms 1272 KB
random_3 AC 81 ms 1780 KB
random_4 AC 26 ms 768 KB
random_5 AC 43 ms 1144 KB
random_6 AC 104 ms 2164 KB
random_7 AC 74 ms 1656 KB
random_8 AC 95 ms 2036 KB
random_9 AC 151 ms 2932 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 1 ms 256 KB