답안 #853897

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
853897 2023-09-25T12:36:59 Z vuavisao 무지개나라 (APIO17_rainbow) C++17
11 / 100
3000 ms 1940 KB
#ifndef LOCAL
    #include "rainbow.h"
#endif
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define ll long long
using namespace std;

const int N = 1e5 + 10;
const int dx[] = {- 1, 0, 0, 1};
const int dy[] = {0, - 1, 1, 0};

int n, m, q;
int len, x, y;
char s[N];

bool un_go[60][60];
bool visited[60][60];

void init(int R, int C, int sr, int sc, int M, char *S) {
    n = R; m = C; x = sr; y = sc; len = M;
    for(int i = 0; i < len; ++ i) s[i] = S[i];

    un_go[x][y] = true;
    for(int i = 0; i < len; ++ i) {
        if(s[i] == 'N') -- x;
        else if(s[i] == 'S') ++ x;
        else if(s[i] == 'E') ++ y;
        else -- y;
        un_go[x][y] = true;
    }
}

int colour(int ar, int ac, int br, int bc) {
    int up = ar, le = ac, down = br, ri = bc;
    int res = 0;
    memset(visited, false, sizeof(visited));
    for(int i = up; i <= down; ++ i) {
        for(int j = le; j <= ri; ++ j) {
            if(un_go[i][j] || visited[i][j]) continue;
            auto inside = [&] (int x, int y) -> bool {
                return (up <= x && x <= down && le <= y && y <= ri && !visited[x][y] && !un_go[x][y]);
            };
            ++ res;
            queue<pair<int, int>> q = {};
            visited[i][j] = true; q.push(make_pair(i, j));
            while(!q.empty()) {
                auto [u, v] = q.front(); q.pop();
                for(int k = 0; k < 4; ++ k) {
                    int r = u + dx[k], c = v + dy[k];
                    if(!inside(r, c)) continue;
                    visited[r][c] = true;
                    q.push(make_pair(r, c));
                }
            }
        }
    }
    return res;
}

/// Code by vuavisao
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 9 ms 348 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 9 ms 344 KB Output is correct
12 Correct 10 ms 344 KB Output is correct
13 Correct 6 ms 344 KB Output is correct
14 Correct 8 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Execution timed out 3025 ms 1940 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1 ms 856 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 9 ms 348 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 9 ms 344 KB Output is correct
12 Correct 10 ms 344 KB Output is correct
13 Correct 6 ms 344 KB Output is correct
14 Correct 8 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Runtime error 1 ms 1116 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 9 ms 348 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 9 ms 344 KB Output is correct
12 Correct 10 ms 344 KB Output is correct
13 Correct 6 ms 344 KB Output is correct
14 Correct 8 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Runtime error 1 ms 1116 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -