이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |