Submission #559582

# Submission time Handle Problem Language Result Execution time Memory
559582 2022-05-10T08:40:27 Z SSRS Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
1 ms 668 KB
#include <bits/stdc++.h>
#include "rainbow.h"
using namespace std;
int xmin, xmax, ymin, ymax;
vector<vector<int>> S1, S2, S3, S4;
void init(int R, int C, int sr, int sc, int M, char *S){
  assert(R <= 1000 && C <= 1000);
  sr--;
  sc--;
  vector<int> x(M + 1), y(M + 1);
  x[0] = sr;
  y[0] = sc;
  for (int i = 0; i < M; i++){
    x[i + 1] = x[i];
    y[i + 1] = y[i];
    if (S[i] == 'N'){
      x[i + 1]--;
    }
    if (S[i] == 'S'){
      x[i + 1]++;
    }
    if (S[i] == 'E'){
      y[i + 1]++;
    }
    if (S[i] == 'W'){
      y[i + 1]--;
    }
  }
  xmin = sr;
  xmax = sr;
  ymin = sc;
  ymax = sc;
  for (int i = 1; i <= M; i++){
    xmin = min(xmin, x[i]);
    xmax = max(xmax, x[i]);
    ymin = min(ymin, y[i]);
    ymax = max(ymax, y[i]);
  }
  vector<vector<bool>> river(R, vector<bool>(C, false));
  for (int i = 0; i <= M; i++){
    river[x[i]][y[i]] = true;
  }
  S1 = vector<vector<int>>(R + 1, vector<int>(C + 1, 0));
  for (int i = 0; i < R; i++){
    for (int j = 0; j < C; j++){
      S1[i + 1][j + 1] = S1[i + 1][j] + S1[i][j + 1] - S1[i][j];
      if (!river[i][j]){
        S1[i + 1][j + 1]++;
      }
    }
  }
  S2 = vector<vector<int>>(R, vector<int>(C + 1, 0));
  for (int i = 0; i < R - 1; i++){
    for (int j = 0; j < C; j++){
      S2[i + 1][j + 1] = S2[i + 1][j] + S2[i][j + 1] - S2[i][j];
      if (!river[i][j] && !river[i + 1][j]){
        S2[i + 1][j + 1]++;
      }
    }
  }
  S3 = vector<vector<int>>(R + 1, vector<int>(C, 0));
  for (int i = 0; i < R; i++){
    for (int j = 0; j < C - 1; j++){
      S3[i + 1][j + 1] = S3[i + 1][j] + S3[i][j + 1] - S3[i][j];
      if (!river[i][j] && !river[i][j + 1]){
        S3[i + 1][j + 1]++;
      }
    }
  }
  S4 = vector<vector<int>>(R, vector<int>(C, 0));
  for (int i = 0; i < R - 1; i++){
    for (int j = 0; j < C - 1; j++){
      S4[i + 1][j + 1] = S4[i + 1][j] + S4[i][j + 1] - S4[i][j];
      if (!river[i][j] && !river[i][j + 1] && !river[i + 1][j] && !river[i + 1][j + 1]){
        S4[i + 1][j + 1]++;
      }
    }
  }
}
int colour(int ar, int ac, int br, int bc){
  ar--;
  ac--;
  int ans = 0;
  ans += S1[br][bc] - S1[ar][bc] - S1[br][ac] + S1[ar][ac];
  ans -= S2[br - 1][bc] - S2[ar][bc] - S2[br - 1][ac] + S2[ar][ac];
  ans -= S3[br][bc - 1] - S3[ar][bc - 1] - S3[br][ac] + S3[ar][ac];
  ans += S4[br - 1][bc - 1] - S4[ar][bc - 1] - S4[br - 1][ac] + S4[ar][ac];
  if (ar < xmin && xmax < br && ac < ymin && ymax < bc){
    ans++;
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 400 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 312 KB Output isn't correct
3 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 668 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 400 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 400 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -