답안 #250753

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250753 2020-07-19T04:15:51 Z balbit 무지개나라 (APIO17_rainbow) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define f first
#define s second

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S&&...y){cerr<<x<<", "; _do(y...);}
#define IOS()
#else
#define IOS() ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define bug(...)
#endif // BALBIT

#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

#ifndef BALBIT
#include "rainbow.h"
#endif

int n,m;
vector<pii> pts;

bool H(pii &p) {
    return *lower_bound(ALL(pts), p) == p;
}
const int maxn = 3e5+5;
bool g[60][60];


void init(int R, int C, int sr, int sc, int M, char *S) {
    n = R, m = C;
    pts.pb({sr, sc});
    g[sr-1][sc-1] = 1;
    for (int i = 0; i<M; ++i) {
        if (S[i] == 'N') {
            --sr;
        }
        if (S[i] == 'S') {
            ++sr;
        }
        if (S[i] == 'E') {
            ++sc;
        }
        if (S[i] == 'W') {
            --sc;
        }
        g[sr-1][sc-1] = 1;
    }

//    sort(ALL(pts));
//    pts.resize(unique(ALL(pts)) - pts.begin());
}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int r1, c1, r2, c2;


map<pii, int> dir;

auto cmp = [&](int r, int c) {return r >= r1 && r <= r2 && c >= c1 && c <= c2;};
bool seen[60][60];

void dfs(int i, int j) {
    if (!cmp(i,j) || g[i][j] || seen[i][j]) return;
    seen[i][j] = 1;
    for (int I = 0; I<4; ++I) {
        dfs(i+dx[I], j + dy[I]);
    }
}
int colour(int R1, int C1, int R2, int C2) {
    tie(r1,c1,r2,c2) = tie(R1,C1,R2,C2);
    -- r1; -- c1; --r2; --c2;
    memset(seen, 0, sizeof seen);
    int re = 0;
    for (int i = r1; i<= r2; ++i) {
        for (int j = c1; j<=c2; ++j) {
            if (!seen[i][j]) {
                dfs(i,j); re++;
            }
        }
    }
    return re;

}





#ifdef BALBIT
signed main(){
    IOS();

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