Submission #147633

# Submission time Handle Problem Language Result Execution time Memory
147633 2019-08-30T10:35:28 Z 나라는괴물을막아봐(#3642, ainta) Chessboard Nonogram (FXCUP4_nonogram) C++17
100 / 100
7 ms 640 KB
#include "nonogram.h"
#include<vector>
#include<algorithm>
using namespace std;



std::vector<std::vector<int>> SolveNonogram(int N, int M, std::vector<std::vector<int>> Rclue, std::vector<std::vector<int>> Cclue) {
	int i, j;
	vector<vector<int>>w(N);
	for (i = 0; i < N; i++) {
		w[i].resize(M);
		for (j = 0; j < M; j++) {
			if ((i + j) % 2 == 0)w[i][j] = 1;
		}
	}
	for (i = 0; i < N; i += 2) {
		vector<int>T = Rclue[i];
		int c = 0, pv = 0;
		for (j = 0; j < M; j++) {
			if (w[i][j]) {
				c++;
				continue;
			}
			if (!w[i][j]) {
				if (pv<T.size() && T[pv] > c) {
					w[i][j] = 1;
					c++;
				}
				else {
					c = 0;
					pv++;
				}
			}
		}
	}
	for (i = 0; i < M; i += 2) {
		vector<int>T = Cclue[i];
		int c = 0, pv = 0;
		for (j = 0; j < N; j++) {
			if (w[j][i]) {
				c++;
				continue;
			}
			if (!w[j][i]) {
				if (pv<T.size() && T[pv] > c) {
					w[j][i] = 1;
					c++;
				}
				else {
					c = 0;
					pv++;
				}
			}
		}
	}
	return w;
}

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 (pv<T.size() && T[pv] > c) {
         ~~^~~~~~~~~
nonogram.cpp:46:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (pv<T.size() && T[pv] > c) {
         ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 6 ms 408 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 6 ms 408 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 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 3 ms 512 KB Output is correct
14 Correct 6 ms 512 KB Output is correct
15 Correct 6 ms 512 KB Output is correct