답안 #147856

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147856 2019-08-31T02:29:45 Z zscoder(#3674, zscoder) 체스판 네모네모로직 (FXCUP4_nonogram) C++17
100 / 100
7 ms 640 KB
#include "nonogram.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

std::vector<std::vector<int>> SolveNonogram(int N, int M, std::vector<std::vector<int>> Rclue, std::vector<std::vector<int>> Cclue) 
{
	int n=N; int m=M;
	vector<vi> ans(n);
	for(int i=0;i<n;i++)
	{
		ans[i].resize(m,0);
	}
	for(int i=0;i<n;i+=2)
	{
		vi tmp = Rclue[i];
		int curr=0;
		reverse(tmp.begin(),tmp.end());
		for(int j=0;j<m;j++)
		{
			if(j%2==0)
			{
				ans[i][j]=1;
				curr++; continue;
			}
			if(tmp.empty()) continue;
			if(curr<tmp.back())
			{
				ans[i][j]=1; curr++; continue;
			}
			ans[i][j]=0; tmp.pop_back(); curr=0;
		}
	}
	for(int i=0;i<m;i+=2)
	{
		vi tmp = Cclue[i];
		int curr=0;
		reverse(tmp.begin(),tmp.end());
		for(int j=0;j<n;j++)
		{
			if(j%2==0)
			{
				ans[j][i]=1;
				curr++; continue;
			}
			if(tmp.empty()) continue;
			if(curr<tmp.back())
			{
				ans[j][i]=1; curr++; continue;
			}
			ans[j][i]=0; tmp.pop_back(); curr=0;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if((i+j)%2==0) ans[i][j]=1;
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 6 ms 472 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 6 ms 472 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 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 5 ms 384 KB Output is correct
10 Correct 6 ms 600 KB Output is correct
11 Correct 6 ms 536 KB Output is correct
12 Correct 6 ms 512 KB Output is correct
13 Correct 6 ms 512 KB Output is correct
14 Correct 7 ms 512 KB Output is correct
15 Correct 7 ms 640 KB Output is correct