제출 #984039

#제출 시각아이디문제언어결과실행 시간메모리
984039Unforgettablepl무지개나라 (APIO17_rainbow)C++17
11 / 100
14 ms860 KiB
#include <bits/stdc++.h>
using namespace std;

//#define int long long

bool water[51][51];
bool vis[51][51];
int minx,miny,maxx,maxy;

void dfs(int x,int y){
    if(x<minx or y<miny or x>maxx or y>maxy or vis[x][y] or water[x][y])return;
    vis[x][y]=true;
    dfs(x-1,y);
    dfs(x,y-1);
    dfs(x+1,y);
    dfs(x,y+1);
}

void init(int32_t R, int32_t C, int32_t sr, int32_t sc, int32_t M, char *S) {
    water[sr][sc]=true;
    for(int i=0;i<M;i++){
        if(S[i]=='N')sr--;
        else if(S[i]=='S')sr++;
        else if(S[i]=='E')sc++;
        else if(S[i]=='W')sc--;
        water[sr][sc]=true;
    }
}

int32_t colour(int32_t ar, int32_t ac, int32_t br, int32_t bc) {
    minx = ar;
    miny = ac;
    maxx = br;
    maxy = bc;
    int ans = 0;
    for(auto&i:vis)for(bool&j:i)j=false;
    for(int x=ar;x<=br;x++)for(int y=ac;y<=bc;y++)if(!vis[x][y] and !water[x][y]){ans++;dfs(x,y);}
    return ans;
}
#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...