Submission #562625

# Submission time Handle Problem Language Result Execution time Memory
562625 2022-05-14T20:25:01 Z SSRS Land of the Rainbow Gold (APIO17_rainbow) C++14
11 / 100
3000 ms 1048576 KB
#include <bits/stdc++.h>
#include "rainbow.h"
using namespace std;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
vector<vector<int>> land;
void init(int R, int C, int sr, int sc, int M, char *S){
  sr--;
  sc--;
  land = vector<vector<int>>(R, vector<int>(C, 1));
  int x = sr, y = sc;
  land[x][y] = 0;
  for (int i = 0; i < M; i++){
    if (S[i] == 'N'){
      x--;
    }
    if (S[i] == 'S'){
      x++;
    }
    if (S[i] == 'E'){
      y++;
    }
    if (S[i] == 'W'){
      y--;
    }
    land[x][y] = 0;
  }
}
int colour(int ar, int ac, int br, int bc){
  ar--;
  ac--;
  int R = land.size();
  int C = land[0].size();
  vector<vector<bool>> used(R, vector<bool>(C, false));
  int ans = 0;
  for (int i = ar; i < br; i++){
    for (int j = ac; j < bc; j++){
      if (land[i][j] == 1 && !used[i][j]){
        ans++;
        used[i][j] = true;
        queue<pair<int, int>> Q;
        Q.push(make_pair(i, j));
        while (!Q.empty()){
          int x = Q.front().first;
          int y = Q.front().second;
          Q.pop();
          for (int k = 0; k < 4; k++){
            int x2 = x + dx[k];
            int y2 = y + dy[k];
            if (ar <= x2 && x2 < br && ac <= y2 && y2 < bc){
              if (land[x2][y2] == 1 && !used[x2][y2]){
                used[x2][y2] = true;
                Q.push(make_pair(x2, y2));
              }
            }
          }
        }
      }
    }
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 19 ms 340 KB Output is correct
3 Correct 33 ms 328 KB Output is correct
4 Correct 33 ms 352 KB Output is correct
5 Correct 17 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 31 ms 340 KB Output is correct
12 Correct 26 ms 356 KB Output is correct
13 Correct 22 ms 360 KB Output is correct
14 Correct 26 ms 360 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Execution timed out 3065 ms 2900 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Runtime error 558 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 19 ms 340 KB Output is correct
3 Correct 33 ms 328 KB Output is correct
4 Correct 33 ms 352 KB Output is correct
5 Correct 17 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 31 ms 340 KB Output is correct
12 Correct 26 ms 356 KB Output is correct
13 Correct 22 ms 360 KB Output is correct
14 Correct 26 ms 360 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Execution timed out 3076 ms 4648 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 19 ms 340 KB Output is correct
3 Correct 33 ms 328 KB Output is correct
4 Correct 33 ms 352 KB Output is correct
5 Correct 17 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 31 ms 340 KB Output is correct
12 Correct 26 ms 356 KB Output is correct
13 Correct 22 ms 360 KB Output is correct
14 Correct 26 ms 360 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Execution timed out 3076 ms 4648 KB Time limit exceeded
19 Halted 0 ms 0 KB -