제출 #147633

#제출 시각아이디문제언어결과실행 시간메모리
147633나라는괴물을막아봐 (#201)체스판 네모네모로직 (FXCUP4_nonogram)C++17
100 / 100
7 ms640 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...