답안 #562643

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
562643 2022-05-14T20:47:44 Z SSRS 무지개나라 (APIO17_rainbow) C++14
50 / 100
420 ms 1048576 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){
  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 = 1;
  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 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 232 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 71 ms 10056 KB Output is correct
4 Correct 82 ms 10280 KB Output is correct
5 Correct 73 ms 10280 KB Output is correct
6 Correct 71 ms 10200 KB Output is correct
7 Correct 68 ms 10284 KB Output is correct
8 Correct 83 ms 10244 KB Output is correct
9 Correct 86 ms 10180 KB Output is correct
10 Correct 69 ms 10216 KB Output is correct
11 Correct 70 ms 10284 KB Output is correct
12 Correct 60 ms 10292 KB Output is correct
13 Correct 58 ms 10272 KB Output is correct
14 Correct 61 ms 10300 KB Output is correct
15 Correct 56 ms 10272 KB Output is correct
16 Correct 74 ms 10264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 420 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 232 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 95 ms 18872 KB Output is correct
19 Correct 60 ms 4580 KB Output is correct
20 Correct 51 ms 3132 KB Output is correct
21 Correct 50 ms 3612 KB Output is correct
22 Correct 55 ms 4664 KB Output is correct
23 Correct 67 ms 4640 KB Output is correct
24 Correct 69 ms 3164 KB Output is correct
25 Correct 50 ms 3724 KB Output is correct
26 Correct 60 ms 4592 KB Output is correct
27 Correct 98 ms 19112 KB Output is correct
28 Correct 98 ms 19064 KB Output is correct
29 Correct 94 ms 19092 KB Output is correct
30 Correct 94 ms 19080 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 82 ms 19008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 232 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 95 ms 18872 KB Output is correct
19 Correct 60 ms 4580 KB Output is correct
20 Correct 51 ms 3132 KB Output is correct
21 Correct 50 ms 3612 KB Output is correct
22 Correct 55 ms 4664 KB Output is correct
23 Correct 67 ms 4640 KB Output is correct
24 Correct 69 ms 3164 KB Output is correct
25 Correct 50 ms 3724 KB Output is correct
26 Correct 60 ms 4592 KB Output is correct
27 Correct 98 ms 19112 KB Output is correct
28 Correct 98 ms 19064 KB Output is correct
29 Correct 94 ms 19092 KB Output is correct
30 Correct 94 ms 19080 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 82 ms 19008 KB Output is correct
33 Runtime error 420 ms 1048576 KB Execution killed with signal 9
34 Halted 0 ms 0 KB -