Submission #3595806


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

int main() {
	int H, W, a[500][500];
	cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			cin >> a[i][j];
		}
	}


	int f = 0, cnt = 0;

	REP(i, H) {
		REP(j, W) {
			int k, l;
			if (i % 2 == 0) {
				k = j;
				l = W - 1;
			}
			else if (i % 2 == 1) {
				k = W - 1 - j;
				l = 0;
			}

			if (f == 0 && a[i][k] % 2 == 1) {
				f = 1;
			}
			else if (f == 1) {
				cnt++;
				if (a[i][k] % 2 == 1) {
					f = 0;
				}
			}
		}
	}

	cout << cnt << endl;
	f = 0;
	int t = 0;
	REP(i,H) {
		REP(j, W) {
			int k, l, m;
			if (t == cnt) {
				return 0;
			}
			if (i % 2 == 0) {
				k = j;
				l = W - 1;
				m = 1;
			}
			else if (i % 2 == 1) {
				k = W - 1 - j;
				l = 0;
				m = -1;
			}

			if (f == 0 && a[i][k] % 2 == 1) {
				f = 1;
				if (k != l) {
					cout << i + 1 << " " << k + 1 << " " << i + 1 << " " << k + m + 1 << endl;
				}
				else {
					cout << i + 1 << " " << k + 1 << " " << i + 1 + 1 << " " << k + 1 << endl;
				}
				t++;
			}
			else if (f == 1) {
				if (a[i][k] % 2 == 1) {
					f = 0;
				}
				else {
					if (k != l) {
						cout << i + 1 << " " << k + 1 << " " << i + 1 << " " << k + m + 1 << endl;
					}
					else {
						cout << i + 1 << " " << k + 1 << " " << i + 1 + 1 << " " << k + 1 << endl;
					}
					t++;
				}
			}
			
		}
	}


	return 0;
}

Submission Info

Submission Time
Task D - Make Them Even
User futty
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1972 Byte
Status AC
Exec Time 292 ms
Memory 3072 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 3 ms 1280 KB
hand_5 AC 286 ms 3072 KB
hand_6 AC 46 ms 1152 KB
max_1 AC 290 ms 3072 KB
max_10 AC 290 ms 3072 KB
max_2 AC 289 ms 3072 KB
max_3 AC 285 ms 3072 KB
max_4 AC 289 ms 3072 KB
max_5 AC 283 ms 3072 KB
max_6 AC 285 ms 3072 KB
max_7 AC 292 ms 3072 KB
max_8 AC 292 ms 3072 KB
max_9 AC 287 ms 3072 KB
random_1 AC 3 ms 256 KB
random_10 AC 38 ms 768 KB
random_2 AC 61 ms 1408 KB
random_3 AC 90 ms 1536 KB
random_4 AC 29 ms 640 KB
random_5 AC 48 ms 1024 KB
random_6 AC 113 ms 1792 KB
random_7 AC 80 ms 1408 KB
random_8 AC 103 ms 1408 KB
random_9 AC 160 ms 2176 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 1 ms 256 KB