# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147646 | 함수컵 최고~ (#201) | Chessboard Nonogram (FXCUP4_nonogram) | C++17 | 7 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |