Submission #147936

# Submission time Handle Problem Language Result Execution time Memory
147936 2019-08-31T08:18:54 Z pichulia,koosaga,ainta(#3658, pichulia) Chessboard Nonogram (FXCUP4_nonogram) C++17
100 / 100
7 ms 640 KB
#include "nonogram.h"

std::vector<std::vector<int>> SolveNonogram(int n, int m, std::vector<std::vector<int>> Rclue, std::vector<std::vector<int>> Cclue) {
	std::vector<std::vector<int> > a(n);
	int i, j, k;
	for (i = 0; i < n; i++)
	{
		a[i].resize(m);
		for (j = 0; j < m; j++) {
			if((i&1)^(j&1))
				a[i][j] = 0;
			else
				a[i][j] = 1;
		}
	}
	// update
	for (i = 0; i < n; i++) {
		if (i & 1) {

		}
		else {
			k = 0;
			int cnt = 0;
			for (j = 0; j < m; j++) {
				if (a[i][j] == 1) { cnt++; continue; }
				if (k < Rclue[i].size() && Rclue[i][k] == cnt) {
					a[i][j] = 0;
					k++;
					cnt = 0;
				}
				else {
					a[i][j] = 1;
					cnt++;
				}
			}
		}
	}
	for (j = 0; j < m; j++) {
		if (j & 1) {

		}
		else {
			k = 0;
			int cnt = 0;
			for (i = 0; i < n; i++) {
				if (a[i][j] == 1) { cnt++; continue; }
				if (k < Cclue[j].size() && Cclue[j][k] == cnt) {
					a[i][j] = 0;
					k++;
					cnt = 0;
				}
				else {
					a[i][j] = 1;
					cnt++;
				}
			}
		}
	}

	return a;
}

Compilation message

nonogram.cpp: In function 'std::vector<std::vector<int> > SolveNonogram(int, int, std::vector<std::vector<int> >, std::vector<std::vector<int> >)':
nonogram.cpp:26:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (k < Rclue[i].size() && Rclue[i][k] == cnt) {
         ~~^~~~~~~~~~~~~~~~~
nonogram.cpp:47:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (k < Cclue[j].size() && Cclue[j][k] == cnt) {
         ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 512 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 512 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 6 ms 512 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 7 ms 640 KB Output is correct
13 Correct 6 ms 536 KB Output is correct
14 Correct 6 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct