제출 #817841

#제출 시각아이디문제언어결과실행 시간메모리
817841Ozy무지개나라 (APIO17_rainbow)C++17
11 / 100
14 ms828 KiB
#include "rainbow.h" #include <bits/stdc++.h> using namespace std; #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define repa(i,a,b) for(int i = (a); i >= (b); i--) #define pll pair<lli,lli> #define MAX 50 lli dir[8] = {0,0,1,-1,-1,1,0,0}; lli arr[MAX+2][MAX+2], vis[MAX+2][MAX+2]; lli fil,col,res; //solucion subtask #1 void init(int R, int C, int sr, int sc, int M, char *S) { fil = R; col = C; pll pos = {sr,sc}; rep(i,0,M-1) { arr[pos.first][pos.second] = 1; if (S[i] == 'N') pos.first--; if (S[i] == 'S') pos.first++; if (S[i] == 'W') pos.second--; if (S[i] == 'E') pos.second++; } arr[pos.first][pos.second] = 1; //cout << endl; //rep(i,1,fil) { // rep(j,1,col) { // cout << arr[i][j]; // } // cout << endl; //} } void dfs(pll pos) { queue<pll> cola; cola.push(pos); vis[pos.first][pos.second] = 1; pll n_pos; while (!cola.empty()) { pos = cola.front(); cola.pop(); rep(i,0,3) { n_pos.first = pos.first + dir[i]; n_pos.second = pos.second + dir[i+4]; if(arr[n_pos.first][n_pos.second] || vis[n_pos.first][n_pos.second]) continue; vis[n_pos.first][n_pos.second] = 1; cola.push(n_pos); } } } int colour(int ar, int ac, int br, int bc) { rep(i,ar-1,br+1) { rep(j,ac-1,bc+1) { if (i < ar || i > br || j < ac || j > bc) vis[i][j]=1; else vis[i][j] = 0; } } //cout << endl; //rep(i,1,fil) { // rep(j,1,col) { // cout << vis[i][j]; // } // cout << endl; //} res = 0; rep(i,ar,br) { rep(j,ac,bc) { if (vis[i][j] || arr[i][j]) continue; dfs({i,j}); res++; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...