Submission #147666

#TimeUsernameProblemLanguageResultExecution timeMemory
147666몰랑이 (#201)Chessboard Nonogram (FXCUP4_nonogram)C++17
100 / 100
6 ms640 KiB
#include <bits/stdc++.h>
#include "nonogram.h"

using namespace std;

#define Fi first
#define Se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)
typedef tuple<int, int, int> t3;
typedef tuple<int, int, int, int> t4;

std::vector<std::vector<int>> SolveNonogram(int N, int M, std::vector<std::vector<int>> Rclue, std::vector<std::vector<int>> Cclue) {
	vector <vector <int> > ans;
	ans.resize(N); rep(i, N) ans[i].resize(M);
	rep(i, N) rep(j, M) if((i+j)%2 == 0) ans[i][j] = 1;
	for(int i=0;i<N;i++) if(i % 2 == 0) {
			for(int j=0, k=0;j<M;j++) {
				if(k == szz(Rclue[i])) continue;
				if((i+j) % 2 == 0) Rclue[i][k]--;
				else {
					if(Rclue[i][k] == 0) ++k;
					else Rclue[i][k]--, ans[i][j] = 1;
				}
			}
		}
	for(int i=0;i<M;i++) if(i % 2 == 0) {
			for(int j=0, k=0;j<N;j++) {
				if(k == szz(Cclue[i])) continue;
				if((i+j) % 2 == 0) Cclue[i][k]--;
				else {
					if(Cclue[i][k] == 0) ++k;
					else Cclue[i][k]--, ans[j][i] = 1;
				}
			}
		}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...