답안 #559593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
559593 2022-05-10T08:53:33 Z SSRS 무지개나라 (APIO17_rainbow) C++14
38 / 100
94 ms 19872 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 - 1 && ac < ymin && ymax < bc - 1){
    ans++;
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 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 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 404 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 424 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Runtime error 2 ms 724 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 676 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 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 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 404 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 424 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 92 ms 19872 KB Output is correct
19 Correct 59 ms 5336 KB Output is correct
20 Correct 66 ms 3884 KB Output is correct
21 Correct 54 ms 4428 KB Output is correct
22 Correct 51 ms 5324 KB Output is correct
23 Correct 50 ms 5344 KB Output is correct
24 Correct 50 ms 3876 KB Output is correct
25 Correct 52 ms 4364 KB Output is correct
26 Correct 58 ms 5280 KB Output is correct
27 Correct 86 ms 19848 KB Output is correct
28 Correct 89 ms 19848 KB Output is correct
29 Correct 94 ms 19856 KB Output is correct
30 Correct 87 ms 19856 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 73 ms 19852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 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 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 404 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 424 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 92 ms 19872 KB Output is correct
19 Correct 59 ms 5336 KB Output is correct
20 Correct 66 ms 3884 KB Output is correct
21 Correct 54 ms 4428 KB Output is correct
22 Correct 51 ms 5324 KB Output is correct
23 Correct 50 ms 5344 KB Output is correct
24 Correct 50 ms 3876 KB Output is correct
25 Correct 52 ms 4364 KB Output is correct
26 Correct 58 ms 5280 KB Output is correct
27 Correct 86 ms 19848 KB Output is correct
28 Correct 89 ms 19848 KB Output is correct
29 Correct 94 ms 19856 KB Output is correct
30 Correct 87 ms 19856 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 73 ms 19852 KB Output is correct
33 Runtime error 1 ms 676 KB Execution killed with signal 6
34 Halted 0 ms 0 KB -