답안 #416868

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416868 2021-06-03T06:30:05 Z Aldas25 무지개나라 (APIO17_rainbow) C++14
11 / 100
3000 ms 12620 KB
#include "rainbow.h"
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

int id (int x, int y) {
    return x * 1100 + y;
}

int par[1100*1100];
int find (int a) {return par[a] = par[a]==a ? a : find(par[a]);}
bool same (int a, int b) {return find(a) == find(b);}
void unite (int a, int b){
    a = find(a), b = find(b);
    if (a == b) return;
    par[b] = a;
}

bool grid[1100][1100];
int r, c;

void init(int R, int C, int sr, int sc, int M, char *S) {
    r = R;
    c = C;
    int curX = sr, curY = sc;
    FOR(i, 1, r) FOR(j, 1, c) grid[i][j] = true;
    grid[curX][curY] = false;
    FOR(i, 0, M-1) {
        char c = S[i];
        if (c == 'N') curX--;
        else if (c == 'S') curX++;
        else if (c == 'W') curY--;
        else curY++;
        grid[curX][curY] = false;
    }
}

int colour(int ar, int ac, int br, int bc) {
    FOR(i, ar, br) FOR(j, ac, bc) par[id(i,j)] = id(i,j);

    FOR(i, ar, br) FOR(j, ac, bc) {
        if (!grid[i][j]) continue;
        if (i < br && grid[i+1][j]) unite(id(i,j), id(i+1, j));
        if (j < bc && grid[i][j+1]) unite(id(i,j), id(i, j+1));
    }

    int cnt = 0;
    FOR(i, ar, br) FOR(j, ac, bc) {
        if (grid[i][j] && find(id(i,j)) == id(i,j)) cnt++;
        //if (grid[i][j] && find(id(i,j)) == id(i,j)) cout << "  parent  i = " << i << " j = " << j << endl;
    }

    return cnt;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 6 ms 604 KB Output is correct
3 Correct 15 ms 600 KB Output is correct
4 Correct 15 ms 604 KB Output is correct
5 Correct 5 ms 588 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 14 ms 588 KB Output is correct
12 Correct 12 ms 588 KB Output is correct
13 Correct 7 ms 588 KB Output is correct
14 Correct 4 ms 588 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Execution timed out 3051 ms 1764 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 49 ms 12620 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 6 ms 604 KB Output is correct
3 Correct 15 ms 600 KB Output is correct
4 Correct 15 ms 604 KB Output is correct
5 Correct 5 ms 588 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 14 ms 588 KB Output is correct
12 Correct 12 ms 588 KB Output is correct
13 Correct 7 ms 588 KB Output is correct
14 Correct 4 ms 588 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Execution timed out 3066 ms 6140 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 6 ms 604 KB Output is correct
3 Correct 15 ms 600 KB Output is correct
4 Correct 15 ms 604 KB Output is correct
5 Correct 5 ms 588 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 14 ms 588 KB Output is correct
12 Correct 12 ms 588 KB Output is correct
13 Correct 7 ms 588 KB Output is correct
14 Correct 4 ms 588 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Execution timed out 3066 ms 6140 KB Time limit exceeded
19 Halted 0 ms 0 KB -