Submission #1117117

# Submission time Handle Problem Language Result Execution time Memory
1117117 2024-11-22T20:38:57 Z ThegeekKnight16 Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
232 ms 848 KB
#include <bits/stdc++.h>
using namespace std;
#include "rainbow.h"
set<pair<int, int>> relevantes;
set<pair<int, int>> agua;
int dx[] = {1,-1,0,0,1,-1,1,-1};
int dy[] = {0,0,1,-1,1,1,-1,-1};

void dfs(int x, int y, set<pair<int, int>> &marc, int ar, int ac, int br, int bc)
{
    marc.emplace(x, y);

    for (int k = 0; k < 4; k++)
    {
        int hx = x + dx[k], hy = y + dy[k];
        if (hx < ar || hy < ac || hx > br || hy > bc) continue;
        if (agua.count(make_pair(hx, hy)) || marc.count(make_pair(hx, hy))) continue;
        dfs(hx, hy, marc, ar, ac, br, bc);
    }
}

void init(int R, int C, int sr, int sc, int M, char *S) 
{
    agua.emplace(sr, sc);
    for (int k = 0; k < 8; k++) relevantes.emplace(sr+dx[k], sc+dy[k]);

    for (int i = 0; i < M; i++)
    {
        if (S[i] == 'N') sr--;
        else if (S[i] == 'S') sr++;
        else if (S[i] == 'E') sc++;
        else sc--;
        agua.emplace(sr, sc);
        for (int k = 0; k < 8; k++) relevantes.emplace(sr+dx[k], sc+dy[k]);
    }
}

int colour(int ar, int ac, int br, int bc) 
{
    set<pair<int, int>> marc; int numAgua = 0; int resp = 0;
    for (auto [x, y] : relevantes)
    {
        if (x < ar || y < ac || x > br || y > bc) continue;
        if (agua.count(make_pair(x, y))) {numAgua++; continue;}
        if (marc.count(make_pair(x, y))) continue;
        dfs(x, y, marc, ar, ac, br, bc); resp++;
    }

    if (numAgua == 0) return 1;
    return resp;
}

# Verdict Execution time Memory Grader output
1 Correct 18 ms 336 KB Output is correct
2 Correct 109 ms 592 KB Output is correct
3 Correct 196 ms 848 KB Output is correct
4 Correct 232 ms 840 KB Output is correct
5 Correct 104 ms 756 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Incorrect 1 ms 336 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 336 KB Output is correct
2 Correct 109 ms 592 KB Output is correct
3 Correct 196 ms 848 KB Output is correct
4 Correct 232 ms 840 KB Output is correct
5 Correct 104 ms 756 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Incorrect 1 ms 336 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 336 KB Output is correct
2 Correct 109 ms 592 KB Output is correct
3 Correct 196 ms 848 KB Output is correct
4 Correct 232 ms 840 KB Output is correct
5 Correct 104 ms 756 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Incorrect 1 ms 336 KB Output isn't correct
8 Halted 0 ms 0 KB -