답안 #289895

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289895 2020-09-03T08:06:21 Z arman_ferdous Vision Program (IOI19_vision) C++17
100 / 100
61 ms 3008 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

using vi = vector<int>;
const int N = 401;

int H, W, K;

vi getdia1(int r, int c) {
  vi cells;
  for(;;) {
    cells.push_back(r * W + c);
    r--, c++;
    if(r < 0 || c >= W) break;
  }
  return cells;
}

vi getdia2(int r, int c) {
  vi cells;
  for(;;) {
    cells.push_back(r * W + c);
    r--, c--;
    if(r < 0 || c < 0) break;
  }
  return cells;
}

int dia1[N + N], dia2[N + N];
int prefix1[N + N], prefix2[N + N];

void construct_network(int h, int w, int k) {
  H = h, W = w, K = k;

  for(int i = 0; i < h; i++) {
    vi cells = getdia1(i, 0);
    dia1[i] = add_xor(cells);
  }
  for(int j = 1; j < w; j++) {
    vi cells = getdia1(h - 1, j);
    dia1[h - 1 + j] = add_xor(cells);
  }
  for(int i = 0; i < h + w - 1; i++) {
    vi tmp;
    for(int j = 0; j <= i; j++) tmp.push_back(dia1[j]);
    prefix1[i] = add_xor(tmp);
  }
  vi KKdifres, Kdifres;
  for(int i = 0; i + K < h + w - 1; i++) {
    vi tmp(2); 
    tmp[0] = prefix1[i];
    tmp[1] = prefix1[i + K];
    KKdifres.push_back(add_and(tmp));
  }
  for(int i = 0; i + K - 1 < h + w - 1; i++) {
    vi tmp(2);
    tmp[0] = prefix1[i];
    tmp[1] = prefix1[i + K - 1];
    Kdifres.push_back(add_and(tmp));
  }
  int greaterthanK1, greaterthanKK1;
  greaterthanK1 = add_or(Kdifres);
  greaterthanKK1 = add_or(KKdifres);

  for(int i = 0; i < h; i++) {
    vi cells = getdia2(i, w - 1);
    dia2[i - w + 1 + w] = add_xor(cells); 
  }
  for(int j = w - 2; j >= 0; j--) {
    vi cells = getdia2(h - 1, j);
    dia2[h - 1 - j + w] = add_xor(cells);
  }
  for(int i = 1; i <= h - 1 + w; i++) {
    vi tmp;
    for(int j = 1; j <= i; j++) tmp.push_back(dia2[j]);
    prefix2[i] = add_xor(tmp);
  }
  KKdifres.clear(); Kdifres.clear();
  for(int i = 1; i + K <= h + w - 1; i++) {
    vi tmp(2);
    tmp[0] = prefix2[i];
    tmp[1] = prefix2[i + K];
    KKdifres.push_back(add_and(tmp));
  }
  for(int i = 1; i + K - 1 <= h + w - 1; i++) {
    vi tmp(2);
    tmp[0] = prefix2[i];
    tmp[1] = prefix2[i + K - 1];
    Kdifres.push_back(add_and(tmp));
  }
  int greaterthanK2, greaterthanKK2;
  greaterthanK2 = add_or(Kdifres);
  greaterthanKK2 = add_or(KKdifres);

  vi tmp(2);
  tmp[0] = greaterthanKK1, tmp[1] = greaterthanKK2;
  int wrong = add_or(tmp);

  tmp[0] = greaterthanK1, tmp[1] = greaterthanK2;
  int ok = add_or(tmp);

  int notwrong = add_not(wrong);
  tmp[0] = ok, tmp[1] = notwrong;
  add_and(tmp);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 360 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 416 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 360 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 360 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 416 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 360 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 2 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 360 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 416 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 360 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 2 ms 416 KB Output is correct
38 Correct 9 ms 1024 KB Output is correct
39 Correct 2 ms 512 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 5 ms 768 KB Output is correct
42 Correct 5 ms 640 KB Output is correct
43 Correct 10 ms 1024 KB Output is correct
44 Correct 11 ms 1024 KB Output is correct
45 Correct 14 ms 1056 KB Output is correct
46 Correct 9 ms 1024 KB Output is correct
47 Correct 8 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 768 KB Output is correct
2 Correct 9 ms 896 KB Output is correct
3 Correct 6 ms 768 KB Output is correct
4 Correct 8 ms 768 KB Output is correct
5 Correct 8 ms 768 KB Output is correct
6 Correct 6 ms 768 KB Output is correct
7 Correct 7 ms 768 KB Output is correct
8 Correct 7 ms 768 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 6 ms 800 KB Output is correct
11 Correct 7 ms 768 KB Output is correct
12 Correct 6 ms 768 KB Output is correct
13 Correct 8 ms 768 KB Output is correct
14 Correct 7 ms 768 KB Output is correct
15 Correct 6 ms 768 KB Output is correct
16 Correct 6 ms 768 KB Output is correct
17 Correct 7 ms 768 KB Output is correct
18 Correct 8 ms 768 KB Output is correct
19 Correct 8 ms 768 KB Output is correct
20 Correct 8 ms 768 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 9 ms 768 KB Output is correct
9 Correct 8 ms 768 KB Output is correct
10 Correct 8 ms 768 KB Output is correct
11 Correct 8 ms 768 KB Output is correct
12 Correct 6 ms 768 KB Output is correct
13 Correct 6 ms 768 KB Output is correct
14 Correct 6 ms 768 KB Output is correct
15 Correct 6 ms 768 KB Output is correct
16 Correct 8 ms 768 KB Output is correct
17 Correct 6 ms 768 KB Output is correct
18 Correct 7 ms 768 KB Output is correct
19 Correct 5 ms 768 KB Output is correct
20 Correct 19 ms 1920 KB Output is correct
21 Correct 19 ms 1792 KB Output is correct
22 Correct 26 ms 1696 KB Output is correct
23 Correct 18 ms 1656 KB Output is correct
24 Correct 25 ms 1892 KB Output is correct
25 Correct 21 ms 1792 KB Output is correct
26 Correct 19 ms 1664 KB Output is correct
27 Correct 49 ms 2936 KB Output is correct
28 Correct 53 ms 2936 KB Output is correct
29 Correct 61 ms 3004 KB Output is correct
30 Correct 49 ms 2936 KB Output is correct
31 Correct 33 ms 2936 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 2940 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 4 ms 640 KB Output is correct
4 Correct 9 ms 768 KB Output is correct
5 Correct 7 ms 768 KB Output is correct
6 Correct 10 ms 768 KB Output is correct
7 Correct 24 ms 1920 KB Output is correct
8 Correct 26 ms 1912 KB Output is correct
9 Correct 40 ms 2936 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 360 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 416 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 360 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 2 ms 416 KB Output is correct
38 Correct 9 ms 1024 KB Output is correct
39 Correct 2 ms 512 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 5 ms 768 KB Output is correct
42 Correct 5 ms 640 KB Output is correct
43 Correct 10 ms 1024 KB Output is correct
44 Correct 11 ms 1024 KB Output is correct
45 Correct 14 ms 1056 KB Output is correct
46 Correct 9 ms 1024 KB Output is correct
47 Correct 8 ms 1024 KB Output is correct
48 Correct 7 ms 768 KB Output is correct
49 Correct 9 ms 896 KB Output is correct
50 Correct 6 ms 768 KB Output is correct
51 Correct 8 ms 768 KB Output is correct
52 Correct 8 ms 768 KB Output is correct
53 Correct 6 ms 768 KB Output is correct
54 Correct 7 ms 768 KB Output is correct
55 Correct 7 ms 768 KB Output is correct
56 Correct 6 ms 768 KB Output is correct
57 Correct 6 ms 800 KB Output is correct
58 Correct 7 ms 768 KB Output is correct
59 Correct 6 ms 768 KB Output is correct
60 Correct 8 ms 768 KB Output is correct
61 Correct 7 ms 768 KB Output is correct
62 Correct 6 ms 768 KB Output is correct
63 Correct 6 ms 768 KB Output is correct
64 Correct 7 ms 768 KB Output is correct
65 Correct 8 ms 768 KB Output is correct
66 Correct 8 ms 768 KB Output is correct
67 Correct 8 ms 768 KB Output is correct
68 Correct 1 ms 256 KB Output is correct
69 Correct 1 ms 384 KB Output is correct
70 Correct 1 ms 384 KB Output is correct
71 Correct 1 ms 256 KB Output is correct
72 Correct 5 ms 640 KB Output is correct
73 Correct 5 ms 640 KB Output is correct
74 Correct 4 ms 512 KB Output is correct
75 Correct 5 ms 512 KB Output is correct
76 Correct 5 ms 512 KB Output is correct
77 Correct 9 ms 768 KB Output is correct
78 Correct 8 ms 768 KB Output is correct
79 Correct 8 ms 768 KB Output is correct
80 Correct 8 ms 768 KB Output is correct
81 Correct 6 ms 768 KB Output is correct
82 Correct 6 ms 768 KB Output is correct
83 Correct 6 ms 768 KB Output is correct
84 Correct 6 ms 768 KB Output is correct
85 Correct 8 ms 768 KB Output is correct
86 Correct 6 ms 768 KB Output is correct
87 Correct 7 ms 768 KB Output is correct
88 Correct 5 ms 768 KB Output is correct
89 Correct 19 ms 1920 KB Output is correct
90 Correct 19 ms 1792 KB Output is correct
91 Correct 26 ms 1696 KB Output is correct
92 Correct 18 ms 1656 KB Output is correct
93 Correct 25 ms 1892 KB Output is correct
94 Correct 21 ms 1792 KB Output is correct
95 Correct 19 ms 1664 KB Output is correct
96 Correct 49 ms 2936 KB Output is correct
97 Correct 53 ms 2936 KB Output is correct
98 Correct 61 ms 3004 KB Output is correct
99 Correct 49 ms 2936 KB Output is correct
100 Correct 33 ms 2936 KB Output is correct
101 Correct 1 ms 384 KB Output is correct
102 Correct 1 ms 256 KB Output is correct
103 Correct 47 ms 2940 KB Output is correct
104 Correct 1 ms 384 KB Output is correct
105 Correct 4 ms 640 KB Output is correct
106 Correct 9 ms 768 KB Output is correct
107 Correct 7 ms 768 KB Output is correct
108 Correct 10 ms 768 KB Output is correct
109 Correct 24 ms 1920 KB Output is correct
110 Correct 26 ms 1912 KB Output is correct
111 Correct 40 ms 2936 KB Output is correct
112 Correct 1 ms 256 KB Output is correct
113 Correct 0 ms 384 KB Output is correct
114 Correct 35 ms 3008 KB Output is correct
115 Correct 7 ms 768 KB Output is correct
116 Correct 7 ms 768 KB Output is correct
117 Correct 18 ms 1664 KB Output is correct
118 Correct 18 ms 1912 KB Output is correct
119 Correct 32 ms 2936 KB Output is correct
120 Correct 32 ms 2940 KB Output is correct
121 Correct 36 ms 2972 KB Output is correct
122 Correct 30 ms 2944 KB Output is correct
123 Correct 39 ms 2936 KB Output is correct
124 Correct 34 ms 2988 KB Output is correct
125 Correct 31 ms 2976 KB Output is correct
126 Correct 30 ms 2988 KB Output is correct
127 Correct 30 ms 2884 KB Output is correct
128 Correct 30 ms 2808 KB Output is correct