답안 #171763

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171763 2019-12-30T10:39:08 Z AlexLuchianov Vision Program (IOI19_vision) C++14
100 / 100
89 ms 9952 KB
#include "vision.h"
#include <vector>
#include <algorithm>
#include <iostream>
#include <fstream>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

std::ifstream in ("log2.txt");

int const nmax = 1000;

struct Point{
  int x;
  int y;
  int id;
} v[1 + nmax * nmax];
std::vector<int> line[1 + nmax * 2], col[1 + nmax * 2];
int answer[1 + nmax];

int lineor[1 + nmax], linexor[1 + nmax];
int color[1 + nmax], colxor[1 + nmax];

int n, m, lim;

int solve(int k){
  std::vector<int> sol;
  for(int i = 0; i < lim; i++){
    std::vector<int> aux_or, aux_xor;
    for(int j = MAX(0, i - k); j <= i; j++){
      aux_or.push_back(lineor[j]);
      aux_xor.push_back(linexor[j]);
    }
    int pos1 = add_or(aux_or);
    int pos2 = add_xor(aux_xor);
    pos2 = add_not(pos2);
    pos1 = add_and({pos1, pos2});
    sol.push_back(pos1);
  }
  int solx = add_or(sol);
  sol.clear();
  for(int i = 0; i < lim; i++){
    std::vector<int> aux_or, aux_xor;
    for(int j = MAX(0, i - k); j <= i; j++){
      aux_or.push_back(color[j]);
      aux_xor.push_back(colxor[j]);
    }
    int pos1 = add_or(aux_or);
    int pos2 = add_xor(aux_xor);
    pos2 = add_not(pos2);
    pos1 = add_and({pos1, pos2});
    sol.push_back(pos1);
  }
  int soly = add_or(sol);
  return add_and({solx, soly});
}

void construct_network(int H, int W, int K) {
  for(int i = 0; i < 94; i++)
    in >> answer[i];

	n = H;
	m = W;
	int ptr = 0;
	lim = n + m - 1;
	for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++){
      v[ptr] = {i + j, i - j + m - 1, ptr};
      line[v[ptr].x].push_back(ptr);
      col[v[ptr].y].push_back(ptr);
      ptr++;
    }

  for(int i = 0; i < lim; i++) {
    lineor[i] = add_or(line[i]);
    linexor[i] = add_xor(line[i]);
  }
  for(int i = 0; i < lim; i++){
    color[i] = add_or(col[i]);
    colxor[i] = add_xor(col[i]);
  }
  int pos1 = solve(K - 1), pos2 = solve(K);
  pos1 = add_not(pos1);
  add_and({pos1, pos2});
}
/*
2 3 3
0 0 0 1
0 0 0 2
0 0 1 0
0 0 1 1
0 0 1 2
0 1 0 2
0 1 1 0
0 1 1 1
0 1 1 2
0 2 1 0
0 2 1 1
0 2 1 2
1 0 1 1
1 0 1 2
1 1 1 2
-1

*/

# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 500 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 504 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 500 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 504 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 4 ms 636 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 4 ms 632 KB Output is correct
32 Correct 3 ms 476 KB Output is correct
33 Correct 3 ms 632 KB Output is correct
34 Correct 4 ms 632 KB Output is correct
35 Correct 4 ms 632 KB Output is correct
36 Correct 4 ms 724 KB Output is correct
37 Correct 5 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 500 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 504 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 4 ms 636 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 4 ms 632 KB Output is correct
32 Correct 3 ms 476 KB Output is correct
33 Correct 3 ms 632 KB Output is correct
34 Correct 4 ms 632 KB Output is correct
35 Correct 4 ms 632 KB Output is correct
36 Correct 4 ms 724 KB Output is correct
37 Correct 5 ms 760 KB Output is correct
38 Correct 16 ms 2040 KB Output is correct
39 Correct 5 ms 764 KB Output is correct
40 Correct 7 ms 892 KB Output is correct
41 Correct 6 ms 988 KB Output is correct
42 Correct 16 ms 1784 KB Output is correct
43 Correct 8 ms 1400 KB Output is correct
44 Correct 16 ms 2040 KB Output is correct
45 Correct 22 ms 2488 KB Output is correct
46 Correct 25 ms 2808 KB Output is correct
47 Correct 25 ms 2892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 760 KB Output is correct
2 Correct 16 ms 1784 KB Output is correct
3 Correct 16 ms 1784 KB Output is correct
4 Correct 20 ms 2040 KB Output is correct
5 Correct 4 ms 760 KB Output is correct
6 Correct 13 ms 1528 KB Output is correct
7 Correct 18 ms 1916 KB Output is correct
8 Correct 19 ms 2040 KB Output is correct
9 Correct 4 ms 760 KB Output is correct
10 Correct 11 ms 1272 KB Output is correct
11 Correct 16 ms 1784 KB Output is correct
12 Correct 16 ms 1656 KB Output is correct
13 Correct 19 ms 1912 KB Output is correct
14 Correct 20 ms 2040 KB Output is correct
15 Correct 4 ms 760 KB Output is correct
16 Correct 11 ms 1272 KB Output is correct
17 Correct 16 ms 1656 KB Output is correct
18 Correct 16 ms 1784 KB Output is correct
19 Correct 20 ms 1912 KB Output is correct
20 Correct 21 ms 2040 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 8 ms 1144 KB Output is correct
5 Correct 10 ms 1272 KB Output is correct
6 Correct 11 ms 1400 KB Output is correct
7 Correct 11 ms 1400 KB Output is correct
8 Correct 9 ms 1080 KB Output is correct
9 Correct 14 ms 1528 KB Output is correct
10 Correct 16 ms 1912 KB Output is correct
11 Correct 26 ms 2040 KB Output is correct
12 Correct 38 ms 2168 KB Output is correct
13 Correct 4 ms 760 KB Output is correct
14 Correct 12 ms 1400 KB Output is correct
15 Correct 18 ms 1912 KB Output is correct
16 Correct 20 ms 2040 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 16 ms 1656 KB Output is correct
19 Correct 21 ms 2012 KB Output is correct
20 Correct 14 ms 2164 KB Output is correct
21 Correct 35 ms 4148 KB Output is correct
22 Correct 47 ms 5208 KB Output is correct
23 Correct 51 ms 5592 KB Output is correct
24 Correct 14 ms 2040 KB Output is correct
25 Correct 47 ms 4724 KB Output is correct
26 Correct 55 ms 5748 KB Output is correct
27 Correct 24 ms 3572 KB Output is correct
28 Correct 53 ms 6284 KB Output is correct
29 Correct 73 ms 8180 KB Output is correct
30 Correct 86 ms 9460 KB Output is correct
31 Correct 88 ms 9952 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 3540 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 5 ms 888 KB Output is correct
4 Correct 6 ms 1116 KB Output is correct
5 Correct 4 ms 760 KB Output is correct
6 Correct 4 ms 760 KB Output is correct
7 Correct 14 ms 2164 KB Output is correct
8 Correct 14 ms 2164 KB Output is correct
9 Correct 23 ms 3572 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 500 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 504 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 4 ms 636 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 4 ms 632 KB Output is correct
32 Correct 3 ms 476 KB Output is correct
33 Correct 3 ms 632 KB Output is correct
34 Correct 4 ms 632 KB Output is correct
35 Correct 4 ms 632 KB Output is correct
36 Correct 4 ms 724 KB Output is correct
37 Correct 5 ms 760 KB Output is correct
38 Correct 16 ms 2040 KB Output is correct
39 Correct 5 ms 764 KB Output is correct
40 Correct 7 ms 892 KB Output is correct
41 Correct 6 ms 988 KB Output is correct
42 Correct 16 ms 1784 KB Output is correct
43 Correct 8 ms 1400 KB Output is correct
44 Correct 16 ms 2040 KB Output is correct
45 Correct 22 ms 2488 KB Output is correct
46 Correct 25 ms 2808 KB Output is correct
47 Correct 25 ms 2892 KB Output is correct
48 Correct 4 ms 760 KB Output is correct
49 Correct 16 ms 1784 KB Output is correct
50 Correct 16 ms 1784 KB Output is correct
51 Correct 20 ms 2040 KB Output is correct
52 Correct 4 ms 760 KB Output is correct
53 Correct 13 ms 1528 KB Output is correct
54 Correct 18 ms 1916 KB Output is correct
55 Correct 19 ms 2040 KB Output is correct
56 Correct 4 ms 760 KB Output is correct
57 Correct 11 ms 1272 KB Output is correct
58 Correct 16 ms 1784 KB Output is correct
59 Correct 16 ms 1656 KB Output is correct
60 Correct 19 ms 1912 KB Output is correct
61 Correct 20 ms 2040 KB Output is correct
62 Correct 4 ms 760 KB Output is correct
63 Correct 11 ms 1272 KB Output is correct
64 Correct 16 ms 1656 KB Output is correct
65 Correct 16 ms 1784 KB Output is correct
66 Correct 20 ms 1912 KB Output is correct
67 Correct 21 ms 2040 KB Output is correct
68 Correct 2 ms 376 KB Output is correct
69 Correct 2 ms 376 KB Output is correct
70 Correct 3 ms 504 KB Output is correct
71 Correct 2 ms 504 KB Output is correct
72 Correct 5 ms 760 KB Output is correct
73 Correct 8 ms 1144 KB Output is correct
74 Correct 10 ms 1272 KB Output is correct
75 Correct 11 ms 1400 KB Output is correct
76 Correct 11 ms 1400 KB Output is correct
77 Correct 9 ms 1080 KB Output is correct
78 Correct 14 ms 1528 KB Output is correct
79 Correct 16 ms 1912 KB Output is correct
80 Correct 26 ms 2040 KB Output is correct
81 Correct 38 ms 2168 KB Output is correct
82 Correct 4 ms 760 KB Output is correct
83 Correct 12 ms 1400 KB Output is correct
84 Correct 18 ms 1912 KB Output is correct
85 Correct 20 ms 2040 KB Output is correct
86 Correct 5 ms 760 KB Output is correct
87 Correct 16 ms 1656 KB Output is correct
88 Correct 21 ms 2012 KB Output is correct
89 Correct 14 ms 2164 KB Output is correct
90 Correct 35 ms 4148 KB Output is correct
91 Correct 47 ms 5208 KB Output is correct
92 Correct 51 ms 5592 KB Output is correct
93 Correct 14 ms 2040 KB Output is correct
94 Correct 47 ms 4724 KB Output is correct
95 Correct 55 ms 5748 KB Output is correct
96 Correct 24 ms 3572 KB Output is correct
97 Correct 53 ms 6284 KB Output is correct
98 Correct 73 ms 8180 KB Output is correct
99 Correct 86 ms 9460 KB Output is correct
100 Correct 88 ms 9952 KB Output is correct
101 Correct 2 ms 376 KB Output is correct
102 Correct 2 ms 504 KB Output is correct
103 Correct 23 ms 3540 KB Output is correct
104 Correct 2 ms 376 KB Output is correct
105 Correct 5 ms 888 KB Output is correct
106 Correct 6 ms 1116 KB Output is correct
107 Correct 4 ms 760 KB Output is correct
108 Correct 4 ms 760 KB Output is correct
109 Correct 14 ms 2164 KB Output is correct
110 Correct 14 ms 2164 KB Output is correct
111 Correct 23 ms 3572 KB Output is correct
112 Correct 2 ms 504 KB Output is correct
113 Correct 2 ms 376 KB Output is correct
114 Correct 52 ms 6208 KB Output is correct
115 Correct 20 ms 2064 KB Output is correct
116 Correct 4 ms 760 KB Output is correct
117 Correct 50 ms 5620 KB Output is correct
118 Correct 26 ms 3188 KB Output is correct
119 Correct 73 ms 8180 KB Output is correct
120 Correct 72 ms 8160 KB Output is correct
121 Correct 72 ms 8308 KB Output is correct
122 Correct 73 ms 8180 KB Output is correct
123 Correct 24 ms 3572 KB Output is correct
124 Correct 53 ms 6260 KB Output is correct
125 Correct 72 ms 8180 KB Output is correct
126 Correct 73 ms 8296 KB Output is correct
127 Correct 85 ms 9560 KB Output is correct
128 Correct 89 ms 9840 KB Output is correct