Submission #147646

# Submission time Handle Problem Language Result Execution time Memory
147646 2019-08-30T10:55:19 Z 함수컵 최고~(#3641, tlwpdus) Chessboard Nonogram (FXCUP4_nonogram) C++17
0 / 100
7 ms 384 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 += Rclue[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 5 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Runtime error 6 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Runtime error 6 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -