제출 #147856

#제출 시각아이디문제언어결과실행 시간메모리
147856zscoder (#201)Chessboard Nonogram (FXCUP4_nonogram)C++17
100 / 100
7 ms640 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...