Submission #408618

# Submission time Handle Problem Language Result Execution time Memory
408618 2021-05-19T09:42:38 Z dannyboy20031204 Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
3000 ms 664012 KB
#include <bits/stdc++.h>
#include "rainbow.h"
using namespace std;
#define ll long long
#define fi first
#define se second
ll inf = 1ll << 60;
int r, c, m, r0, c0, r1, c1, r2, c2;
char *s;
map<pair<int, int>, bool> is, is2, vis;
bool valid(int i, int j){
     if (i > r2 or i < r1) return false;
     if (j > c2 or j < c1) return false;
     if (is[{i, j}]) return false;
     return true;
}
void dfs(int i, int j){
     vis[{i, j}] = true;
     if (is2[{i + 1, j}] and !vis[{i + 1, j}]) dfs(i + 1, j);
     if (is2[{i - 1, j}] and !vis[{i - 1, j}]) dfs(i - 1, j);
     if (is2[{i, j + 1}] and !vis[{i, j + 1}]) dfs(i, j + 1);
     if (is2[{i, j - 1}] and !vis[{i, j - 1}]) dfs(i, j - 1);
}
vector<pair<int, int>> a;
void init(int _r, int _c, int _r0, int _c0, int _m, char *_s){
     r = _r, c = _c, m = _m, r0 = _r0, c0 = _c0, s = _s;
     a.push_back({r0, c0});
     int x = r0, y = c0;
     for (int i = 0; i < m; i++){
          if (s[i] == 'S') x++;
          if (s[i] == 'N') x--;
          if (s[i] == 'E') y++;
          if (s[i] == 'W') y--;
          a.push_back({x, y});
          is[{x, y}] = true;
     }
}
int colour(int _r1, int _c1, int _r2, int _c2){
     is2.clear();
     vis.clear();
     r1 = _r1, c1 = _c1, r2 = _r2, c2 = _c2;
     vector<pair<int, int>> b;
     a.push_back({r0, c0});
     for (int i = r1; i < r2; i++){
          for (int j = c1; j < c2; j++) if (!is[{i, j}]) b.push_back({i, j});
     }
     int ans = 0;
     for (auto i : b) is2[i] = true;
     for (auto i : b){
          if (!vis[i]){
               dfs(i.fi, i.se);
               ans++;
          }
     }
     return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Execution timed out 3124 ms 664012 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -