Submission #147647

# Submission time Handle Problem Language Result Execution time Memory
147647 2019-08-30T10:56:22 Z 함수컵 최고~(#3641, tlwpdus) Chessboard Nonogram (FXCUP4_nonogram) C++17
100 / 100
7 ms 640 KB
#include "nonogram.h"
#include <bits/stdc++.h>

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) {
    vector<vector<int>> ans(N,vector<int>(M,0));
    if (M%2==0) {
        for (int i=0;i<N;i++) {
            int s = 0;
            for (int &v : Rclue[i]) s+=v;
            s += (int)Rclue[i].size()-1;
            int ti = 0;
            if (s==M-1&&i%2) ti = 1;
            for (int j=0;j<Rclue[i].size();j++){
                for (int k=ti;k<ti+Rclue[i][j];k++) {
                    ans[i][k] = 1;
                }
                ti += Rclue[i][j]+1;
            }
        }
        return ans;
    }
    if (N%2==0) {
        for (int i=0;i<M;i++) {
            int s = 0;
            for (int &v : Cclue[i]) s+=v;
            s += (int)Cclue[i].size()-1;
            int ti = 0;
            if (s==N-1&&i%2) ti = 1;
            for (int j=0;j<Cclue[i].size();j++){
                for (int k=ti;k<ti+Cclue[i][j];k++) {
                    ans[k][i] = 1;
                }
                ti += Cclue[i][j]+1;
            }
        }
        return ans;
    }for (int i=0;i<N;i+=2) {
            int s = 0;
            for (int &v : Rclue[i]) s+=v;
            s += (int)Rclue[i].size()-1;
            int ti = 0;
            if (s==M-1&&i%2) ti = 1;
            for (int j=0;j<Rclue[i].size();j++){
                for (int k=ti;k<ti+Rclue[i][j];k++) {
                    ans[i][k] = 1;
                }
                ti += Rclue[i][j]+1;
            }
        }
        for (int i=0;i<M;i+=2) {
            int s = 0;
            for (int &v : Cclue[i]) s+=v;
            s += (int)Cclue[i].size()-1;
            int ti = 0;
            if (s==N-1&&i%2) ti = 1;
            for (int j=0;j<Cclue[i].size();j++){
                for (int k=ti;k<ti+Cclue[i][j];k++) {
                    ans[k][i] = 1;
                }
                ti += Cclue[i][j]+1;
            }
        }
        for (int i=1;i<N;i+=2) {
            for (int j=1;j<M;j+=2) {
                ans[i][j] = 1;
            }
        }
        return ans;
}

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:15:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<Rclue[i].size();j++){
                          ~^~~~~~~~~~~~~~~~
nonogram.cpp:31:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<Cclue[i].size();j++){
                          ~^~~~~~~~~~~~~~~~
nonogram.cpp:45:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<Rclue[i].size();j++){
                          ~^~~~~~~~~~~~~~~~
nonogram.cpp:58:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<Cclue[i].size();j++){
                          ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 6 ms 464 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 6 ms 464 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 380 KB Output is correct
10 Correct 7 ms 640 KB Output is correct
11 Correct 7 ms 512 KB Output is correct
12 Correct 6 ms 512 KB Output is correct
13 Correct 7 ms 640 KB Output is correct
14 Correct 7 ms 512 KB Output is correct
15 Correct 7 ms 512 KB Output is correct