Submission #817841

# Submission time Handle Problem Language Result Execution time Memory
817841 2023-08-09T17:46:31 Z Ozy Land of the Rainbow Gold (APIO17_rainbow) C++17
11 / 100
14 ms 828 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a <<  " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli> 

#define MAX 50

lli dir[8] = {0,0,1,-1,-1,1,0,0};
lli arr[MAX+2][MAX+2], vis[MAX+2][MAX+2];
lli fil,col,res;

//solucion subtask #1
void init(int R, int C, int sr, int sc, int M, char *S) {
    fil = R;
    col = C;

    pll pos = {sr,sc};
    rep(i,0,M-1) {
        arr[pos.first][pos.second] = 1;
        if (S[i] == 'N') pos.first--;
        if (S[i] == 'S') pos.first++;
        if (S[i] == 'W') pos.second--;
        if (S[i] == 'E') pos.second++;
    }
    arr[pos.first][pos.second] = 1;

    //cout << endl;
    //rep(i,1,fil) {
    //    rep(j,1,col) {
    //        cout << arr[i][j];
    //    }
    //    cout << endl;
    //}
}

void dfs(pll pos) {

    queue<pll> cola;
    cola.push(pos);
    vis[pos.first][pos.second] = 1;

    pll n_pos;
    while (!cola.empty()) {
        pos = cola.front();
        cola.pop();


        rep(i,0,3) {
            n_pos.first = pos.first + dir[i];
            n_pos.second = pos.second + dir[i+4];

            if(arr[n_pos.first][n_pos.second] || vis[n_pos.first][n_pos.second]) continue;

            vis[n_pos.first][n_pos.second] = 1;
            cola.push(n_pos); 
        }

    }

}

int colour(int ar, int ac, int br, int bc) {
    
    rep(i,ar-1,br+1) {
        rep(j,ac-1,bc+1) {
            if (i < ar || i > br || j < ac || j > bc) vis[i][j]=1;
            else vis[i][j] = 0;
        }
    }

    //cout << endl;
    //rep(i,1,fil) {
    //    rep(j,1,col) {
    //        cout << vis[i][j];
    //    }
    //    cout << endl;
    //}

    res = 0;
    rep(i,ar,br) {
       rep(j,ac,bc) {
            if (vis[i][j] || arr[i][j]) continue;
            dfs({i,j});
            res++;
        }
    }

    return res;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 11 ms 372 KB Output is correct
4 Correct 11 ms 380 KB Output is correct
5 Correct 5 ms 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 14 ms 404 KB Output is correct
12 Correct 8 ms 380 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 8 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Runtime error 1 ms 724 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 11 ms 372 KB Output is correct
4 Correct 11 ms 380 KB Output is correct
5 Correct 5 ms 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 14 ms 404 KB Output is correct
12 Correct 8 ms 380 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 8 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Runtime error 1 ms 828 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 11 ms 372 KB Output is correct
4 Correct 11 ms 380 KB Output is correct
5 Correct 5 ms 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 14 ms 404 KB Output is correct
12 Correct 8 ms 380 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 8 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Runtime error 1 ms 828 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -