답안 #1117088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1117088 2024-11-22T20:08:19 Z hyakup 무지개나라 (APIO17_rainbow) C++17
11 / 100
9 ms 764 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
#define bug(x) cout << #x << " " << x << endl;


const int maxn = 60;
const int inf = 1e9;

int marc[maxn][maxn];
int n, m, q;

int di[] = { 0, 1, 0, -1 };
int dj[] = { 1, 0, -1, 0 };

void init(int R, int C, int sr, int sc, int M, char *S) {
    n = R, m = C;
    marc[sr][sc] = inf;
    for( int i = 0; i < M; i++ ){
        char c = S[i];
        if( c == 'N' ) sr--;
        if( c == 'S' ) sr++;
        if( c == 'W' ) sc--;
        if( c == 'E' ) sc++;

        marc[sr][sc] = inf;
    }
}

int linha1, linha2, coluna1, coluna2;

bool in_bounds( int i, int j ){
    return linha1 <= i && i <= linha2 && coluna1 <= j && j <= coluna2;
}


void dfs( int i, int j ){
    // bug(i);
    // bug(j);
    marc[i][j] = q;
    for( int d = 0; d < 4; d++ ) if( marc[i + di[d]][j + dj[d]] < q && in_bounds( i + di[d], j + dj[d] ) ) dfs( i + di[d], j + dj[d] );
}

int colour(int ar, int ac, int br, int bc) {
    linha1 = ar; coluna1 = ac; linha2 = br; coluna2 = bc;
    q++;
    // bug(ar);
    // bug(ac);
    // bug(br);
    // bug(bc);
    int resp = 0;
    for( int i = ar; i <= br; i++ )
        for( int j = ac; j <= bc; j++ ){
            // cout << i << " " << j << " " << marc[i][j] << endl;
            if( marc[i][j] < q ){ resp++; dfs( i, j ); }
        }

    return resp;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 508 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 6 ms 528 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Runtime error 2 ms 592 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Runtime error 2 ms 764 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 508 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 6 ms 528 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Runtime error 2 ms 592 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 508 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 6 ms 528 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Runtime error 2 ms 592 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -