Submission #4062246
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX
const double EPS = 1e-14;
const double PI = acos(-1.0);
typedef pair<int, int> p;
void solve(int x1, int y1, int x2, int y2) {
FOR (i, x1, x2) {
printf("%d %d %d %d\n", i, y1, i + 1, y1);
}
if (y1 <= y2) {
FOR (i, y1, y2) {
printf("%d %d %d %d\n", x2, i, x2, i + 1);
}
} else {
RFOR (i, y2, y1) {
printf("%d %d %d %d\n", x2, i + 1, x2, i);
}
}
}
int main(){
int h, w;
cin >> h >> w;
int a;
vector<p> v;
FOR (i, 1, h + 1) {
FOR (j, 1, w + 1) {
cin >> a;
if (a % 2 == 1) {
v.push_back(make_pair(i, j));
}
}
}
if (v.size() == 0) {
cout << 0 << endl;
exit(0);
}
int n = 0;
for (int i = 0; i < v.size(); i+=2) {
if (v.size() - 1 <= i) break;
n += abs(v[i].first - v[i + 1].first) + abs(v[i].second - v[i + 1].second);
}
cout << n << endl;
for (int i = 0; i < v.size(); i+=2) {
if (v.size() - 1 <= i) break;
solve(v[i].first, v[i].second, v[i + 1].first, v[i + 1].second);
}
}
Submission Info
Submission Time |
|
Task |
D - Make Them Even |
User |
croonalullaby |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1332 Byte |
Status |
WA |
Exec Time |
107 ms |
Memory |
5236 KB |
Judge Result
Set Name |
All |
Sample |
Score / Max Score |
0 / 400 |
0 / 0 |
Status |
|
|
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 |
1 ms |
256 KB |
hand_4 |
AC |
1 ms |
256 KB |
hand_5 |
AC |
73 ms |
4208 KB |
hand_6 |
AC |
41 ms |
256 KB |
max_1 |
WA |
104 ms |
4980 KB |
max_10 |
WA |
103 ms |
4980 KB |
max_2 |
WA |
101 ms |
4852 KB |
max_3 |
WA |
103 ms |
4980 KB |
max_4 |
WA |
107 ms |
5236 KB |
max_5 |
WA |
104 ms |
4980 KB |
max_6 |
WA |
104 ms |
4980 KB |
max_7 |
WA |
106 ms |
5108 KB |
max_8 |
WA |
105 ms |
5108 KB |
max_9 |
WA |
103 ms |
4980 KB |
random_1 |
WA |
2 ms |
256 KB |
random_10 |
WA |
14 ms |
896 KB |
random_2 |
WA |
22 ms |
1276 KB |
random_3 |
WA |
32 ms |
1656 KB |
random_4 |
WA |
11 ms |
768 KB |
random_5 |
WA |
18 ms |
1020 KB |
random_6 |
WA |
41 ms |
2168 KB |
random_7 |
WA |
30 ms |
1656 KB |
random_8 |
WA |
39 ms |
2040 KB |
random_9 |
WA |
58 ms |
2932 KB |
sample_01 |
AC |
1 ms |
256 KB |
sample_02 |
AC |
1 ms |
256 KB |
sample_03 |
AC |
1 ms |
256 KB |