Submission #610867

# Submission time Handle Problem Language Result Execution time Memory
610867 2022-07-28T16:41:19 Z AugustinasJucas Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
23 ms 700 KB
#include "rainbow.h"
#include <bits/stdc++.h>

using namespace std;
int n, m;

bool is[501][501] = {};
string mas;

void gen(int e, int s) {

    for(auto x : mas) {
        is[e][s] = 1;
        if(x == 'N') e--;
        if(x == 'S') e++;
        if(x == 'W') s--;
        if(x == 'E') s++;
        is[e][s] = 1;
    }

}

void init(int R, int C, int sr, int sc, int M, char *S) {
    n = R; m = C;
    for(int i = 0; i < M; i++) mas.push_back(S[i]);
    gen(sr, sc);
}

int colour(int ar, int ac, int br, int bc) {
    int ret = 0;
    bool vis[501][501] = {};
    vector<pair<int, int> > pos = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
    for(int i = ar; i <= br; i++) {
        for(int j = ac; j <= bc; j++) {
            if(vis[i][j]) continue ;
            if(is[i][j]) continue;
          //  cout << "esu (" << i << ", " << j << ")\n";
            int e = i; int s = j;
            int pe, ps;
            queue<pair<int, int> > q;
            q.push({e, s});
            while(q.size()) {
                e = q.front().first;
                s = q.front().second;
                q.pop();
                for(auto x : pos) {
                    pe = x.first + e; ps = x.second + s;
                    if(pe < ar || pe > br || ps < ac || ps > bc) continue;
                    if(vis[pe][ps]) continue;
                    if(is[pe][ps]) continue;
                    vis[pe][ps] = 1;
                    q.push({pe, ps});
                }
            }
            ret++;
        }
    }
  //  cout << "ret " << ret << endl;
    return ret;
}

# Verdict Execution time Memory Grader output
1 Correct 9 ms 468 KB Output is correct
2 Correct 15 ms 468 KB Output is correct
3 Correct 22 ms 580 KB Output is correct
4 Correct 23 ms 700 KB Output is correct
5 Correct 13 ms 640 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Incorrect 1 ms 468 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 468 KB Output is correct
2 Correct 15 ms 468 KB Output is correct
3 Correct 22 ms 580 KB Output is correct
4 Correct 23 ms 700 KB Output is correct
5 Correct 13 ms 640 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Incorrect 1 ms 468 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 468 KB Output is correct
2 Correct 15 ms 468 KB Output is correct
3 Correct 22 ms 580 KB Output is correct
4 Correct 23 ms 700 KB Output is correct
5 Correct 13 ms 640 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Incorrect 1 ms 468 KB Output isn't correct
8 Halted 0 ms 0 KB -