Submission #3595086


Source Code Expand

#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int a[501][501];
int h,w;
void prt(int i,int j){
    if(i%2==0){
        if(j!=w-1){
            cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
        }else{
            cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
        }
    }else{
        if(j!=0){
            cout << i+1 << " " << j+1 << " " << i+1 << " " << j << endl;
        }else{
            cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
        }
    }

}
int main(){
    cin >> h >> w;
    REP(i,h){
        REP(j,w){
            cin >> a[i][j];
        }
    }
    int count = 0;
    bool moving=false;
    REP(i, h){
        REP(j,w){
            int y = (i%2) * (w-1)  + pow(-1, (i%2)) * j;
            if(moving){
                if(a[i][y]%2==1){
                    moving = false;
                    count++;
                }else{
                }
            }else{
                if(a[i][y]%2==1){
                    moving = true;
                }
            }
        }
    }
    cout << count << endl;
    moving = false;
    REP(i,h){
        REP(j,w){
            int y = (i%2) * (w-1)  + pow(-1, (i%2)) * j;
            if(moving){
                if(a[i][y]%2==0){
                    prt(i,y);
                }else{
                    moving = false;
                    count--;
                }
            }else{
                if(a[i][y]%2==1){
                    moving = 1;
                    prt(i,y);
                }
            }
            if(!count) break;
        }
        if(!count) break;
    }
    return 0;
}

Submission Info

Submission Time
Task D - Make Them Even
User mathda1
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2005 Byte
Status WA
Exec Time 287 ms
Memory 3072 KB

Judge Result

Set Name All Sample
Score / Max Score 0 / 400 0 / 0
Status
AC × 6
WA × 23
AC × 1
WA × 2
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 WA 1 ms 256 KB
hand_3 AC 2 ms 256 KB
hand_4 AC 2 ms 1280 KB
hand_5 AC 277 ms 3072 KB
hand_6 AC 44 ms 1280 KB
max_1 WA 280 ms 3072 KB
max_10 WA 276 ms 3072 KB
max_2 WA 280 ms 3072 KB
max_3 WA 287 ms 3072 KB
max_4 WA 275 ms 3072 KB
max_5 WA 280 ms 3072 KB
max_6 WA 277 ms 3072 KB
max_7 WA 281 ms 3072 KB
max_8 WA 281 ms 3072 KB
max_9 WA 278 ms 3072 KB
random_1 WA 3 ms 256 KB
random_10 WA 37 ms 768 KB
random_2 WA 60 ms 1408 KB
random_3 WA 87 ms 1536 KB
random_4 WA 29 ms 640 KB
random_5 WA 48 ms 1024 KB
random_6 WA 110 ms 1664 KB
random_7 WA 78 ms 1408 KB
random_8 WA 100 ms 1408 KB
random_9 WA 153 ms 2048 KB
sample_01 WA 1 ms 256 KB
sample_02 WA 1 ms 256 KB
sample_03 AC 1 ms 256 KB