답안 #975513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975513 2024-05-05T11:32:52 Z De3b0o 무지개나라 (APIO17_rainbow) C++14
0 / 100
2 ms 348 KB
#include "rainbow.h"
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)

using namespace std;

ll m;
string s;
bool mp[1009][1009];
bool vis[1009][1009];
ll Ar , Ac , Br , Bc;

void river(ll i , ll j , ll idx)
{
    if(idx==m)
        return;
    mp[i][j]=1;
    if(s[idx]=='N')
        river(i-1,j,idx+1);
    if(s[idx]=='S')
        river(i+1,j,idx+1);
    if(s[idx]=='W')
        river(i,j-1,idx+1);
    if(s[idx]=='E')
        river(i,j+1,idx+1);
}

void dfs(ll i , ll j)
{
    if(i<Ar||i>Br||j<Ac||j>Bc||vis[i][j]||mp[i][j])
        return;
    vis[i][j]=1;
    dfs(i+1,j);
    dfs(i-1,j);
    dfs(i,j+1);
    dfs(i,j-1);
}

void init(int R, int C, int sr, int sc, int M, char *S)
{
    s=S;
    m=M;
    river(sr,sc,0);
}

int colour(int ar, int ac, int br, int bc)
{
    ll ans = 0;
    Ar = ar;
    Br = br;
    Ac = ac;
    Bc = bc;
    for(int i = ar ; br>=i ; i++)
    {
        for(int j = ac ; bc>=j ; j++)
        {
            if(vis[i][j]||mp[i][j])
                continue;
            dfs(i,j);
            ans++;
        }
    }
    for(int i = ar ; br>=i ; i++)
        for(int j = ac ; bc>=j ; j++)
            vis[i][j]=0;
    return ans;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -