답안 #161630

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
161630 2019-11-03T11:00:35 Z georgerapeanu Vision Program (IOI19_vision) C++14
100 / 100
94 ms 9236 KB
#include "vision.h"
#pragma once

using namespace std;

const int NMAX = 200;

int sum_diag_pos[2 * NMAX + 5];
int sum2_diag_pos[2 * NMAX + 5];
int diff_diag_pos[2 * NMAX + 5];
int diff2_diag_pos[2 * NMAX + 5];
vector<int> sum_cells[2 * NMAX + 5];
vector<int> diff_cells[2 * NMAX + 5];
int last_ind;

int at_most_k(int n,int m,int k){
    vector<int> ok_sum_k_pos;
    for(int i = 0;i + k < n + m - 1;i++){
        vector<int> tmp;
        for(int j = i;j <= i + k;j++){
            tmp.push_back(sum_diag_pos[j]);
            tmp.push_back(sum2_diag_pos[j]);
        }
        last_ind++;
        add_or(tmp);
        last_ind++;
        add_xor(tmp);
        last_ind++;
        add_not(last_ind - 2);
        ok_sum_k_pos.push_back(last_ind++);
        add_and({last_ind - 2,last_ind - 4});
    }
    int ok_sum_k = last_ind++;
    add_or(ok_sum_k_pos);
    
    vector<int> ok_diff_k_pos;
    for(int i = 0;i + k < n + m - 1;i++){
        vector<int> tmp;
        for(int j = i;j <= i + k;j++){
            tmp.push_back(diff_diag_pos[j]);
            tmp.push_back(diff2_diag_pos[j]);
        }
        last_ind++;
        add_or(tmp);
        last_ind++;
        add_xor(tmp);
        last_ind++;
        add_not(last_ind - 2);
        ok_diff_k_pos.push_back(last_ind++);
        add_and({last_ind - 2,last_ind - 4});
    }
    int ok_diff_k = last_ind++;
    add_or(ok_diff_k_pos);

    last_ind++;
    add_and({ok_diff_k,ok_sum_k});

    return last_ind - 1;
}

void construct_network(int n, int m, int k) {
    last_ind = n * m;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            sum_cells[i + j].push_back(i * m + j);
            diff_cells[i - j + m - 1].push_back(i * m + j);
        }
    }
    for(int sum = 0;sum < n + m - 1;sum++){
        sum_diag_pos[sum] = last_ind++;
        add_or(sum_cells[sum]);
        last_ind++;
        add_xor(sum_cells[sum]);
        last_ind++;
        add_not(last_ind - 2);
        sum2_diag_pos[sum] = last_ind++;
        add_and({last_ind - 2,sum_diag_pos[sum]});
    }
    
    for(int diff = 0;diff < n + m - 1;diff++){
        diff_diag_pos[diff] = last_ind++;
        add_or(diff_cells[diff]);
        last_ind++;
        add_xor(diff_cells[diff]);
        last_ind++;
        add_not(last_ind - 2);
        diff2_diag_pos[diff] = last_ind++;
        add_and({last_ind - 2,diff_diag_pos[diff]});
    }
    int ok1 = at_most_k(n,m,k);
    int ok2 = at_most_k(n,m,k - 1);
    
    add_not(ok2);
    ok2 = last_ind++;

    add_and({ok1,ok2});
}

Compilation message

vision.cpp:2:9: warning: #pragma once in main file
 #pragma once
         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 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 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 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 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 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 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 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 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 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 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 4 ms 504 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 4 ms 504 KB Output is correct
35 Correct 4 ms 504 KB Output is correct
36 Correct 4 ms 504 KB Output is correct
37 Correct 3 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 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 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 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 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 4 ms 504 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 4 ms 504 KB Output is correct
35 Correct 4 ms 504 KB Output is correct
36 Correct 4 ms 504 KB Output is correct
37 Correct 3 ms 380 KB Output is correct
38 Correct 21 ms 2296 KB Output is correct
39 Correct 6 ms 632 KB Output is correct
40 Correct 5 ms 632 KB Output is correct
41 Correct 6 ms 888 KB Output is correct
42 Correct 5 ms 760 KB Output is correct
43 Correct 9 ms 1140 KB Output is correct
44 Correct 21 ms 2424 KB Output is correct
45 Correct 24 ms 2680 KB Output is correct
46 Correct 19 ms 2168 KB Output is correct
47 Correct 7 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 19 ms 1912 KB Output is correct
3 Correct 19 ms 1912 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 5 ms 760 KB Output is correct
6 Correct 18 ms 1784 KB Output is correct
7 Correct 17 ms 1780 KB Output is correct
8 Correct 4 ms 504 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
10 Correct 16 ms 1660 KB Output is correct
11 Correct 19 ms 1912 KB Output is correct
12 Correct 20 ms 1912 KB Output is correct
13 Correct 15 ms 1528 KB Output is correct
14 Correct 3 ms 492 KB Output is correct
15 Correct 5 ms 888 KB Output is correct
16 Correct 16 ms 1656 KB Output is correct
17 Correct 21 ms 2040 KB Output is correct
18 Correct 19 ms 1912 KB Output is correct
19 Correct 14 ms 1528 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 2 ms 252 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 10 ms 1016 KB Output is correct
5 Correct 11 ms 1272 KB Output is correct
6 Correct 9 ms 1016 KB Output is correct
7 Correct 4 ms 504 KB Output is correct
8 Correct 7 ms 888 KB Output is correct
9 Correct 19 ms 1784 KB Output is correct
10 Correct 18 ms 1912 KB Output is correct
11 Correct 15 ms 1692 KB Output is correct
12 Correct 6 ms 764 KB Output is correct
13 Correct 5 ms 760 KB Output is correct
14 Correct 17 ms 1772 KB Output is correct
15 Correct 16 ms 1656 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 19 ms 1916 KB Output is correct
19 Correct 3 ms 504 KB Output is correct
20 Correct 15 ms 1908 KB Output is correct
21 Correct 46 ms 4852 KB Output is correct
22 Correct 45 ms 4728 KB Output is correct
23 Correct 12 ms 1528 KB Output is correct
24 Correct 15 ms 2036 KB Output is correct
25 Correct 49 ms 5236 KB Output is correct
26 Correct 12 ms 1528 KB Output is correct
27 Correct 26 ms 3056 KB Output is correct
28 Correct 71 ms 7668 KB Output is correct
29 Correct 86 ms 9076 KB Output is correct
30 Correct 76 ms 7412 KB Output is correct
31 Correct 22 ms 2680 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 3084 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 11 ms 760 KB Output is correct
4 Correct 7 ms 1012 KB Output is correct
5 Correct 5 ms 760 KB Output is correct
6 Correct 5 ms 760 KB Output is correct
7 Correct 14 ms 1908 KB Output is correct
8 Correct 15 ms 1908 KB Output is correct
9 Correct 25 ms 3056 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 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 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 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 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 4 ms 504 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 4 ms 504 KB Output is correct
35 Correct 4 ms 504 KB Output is correct
36 Correct 4 ms 504 KB Output is correct
37 Correct 3 ms 380 KB Output is correct
38 Correct 21 ms 2296 KB Output is correct
39 Correct 6 ms 632 KB Output is correct
40 Correct 5 ms 632 KB Output is correct
41 Correct 6 ms 888 KB Output is correct
42 Correct 5 ms 760 KB Output is correct
43 Correct 9 ms 1140 KB Output is correct
44 Correct 21 ms 2424 KB Output is correct
45 Correct 24 ms 2680 KB Output is correct
46 Correct 19 ms 2168 KB Output is correct
47 Correct 7 ms 1016 KB Output is correct
48 Correct 5 ms 760 KB Output is correct
49 Correct 19 ms 1912 KB Output is correct
50 Correct 19 ms 1912 KB Output is correct
51 Correct 3 ms 504 KB Output is correct
52 Correct 5 ms 760 KB Output is correct
53 Correct 18 ms 1784 KB Output is correct
54 Correct 17 ms 1780 KB Output is correct
55 Correct 4 ms 504 KB Output is correct
56 Correct 5 ms 760 KB Output is correct
57 Correct 16 ms 1660 KB Output is correct
58 Correct 19 ms 1912 KB Output is correct
59 Correct 20 ms 1912 KB Output is correct
60 Correct 15 ms 1528 KB Output is correct
61 Correct 3 ms 492 KB Output is correct
62 Correct 5 ms 888 KB Output is correct
63 Correct 16 ms 1656 KB Output is correct
64 Correct 21 ms 2040 KB Output is correct
65 Correct 19 ms 1912 KB Output is correct
66 Correct 14 ms 1528 KB Output is correct
67 Correct 3 ms 376 KB Output is correct
68 Correct 2 ms 252 KB Output is correct
69 Correct 2 ms 376 KB Output is correct
70 Correct 2 ms 380 KB Output is correct
71 Correct 2 ms 376 KB Output is correct
72 Correct 5 ms 760 KB Output is correct
73 Correct 10 ms 1016 KB Output is correct
74 Correct 11 ms 1272 KB Output is correct
75 Correct 9 ms 1016 KB Output is correct
76 Correct 4 ms 504 KB Output is correct
77 Correct 7 ms 888 KB Output is correct
78 Correct 19 ms 1784 KB Output is correct
79 Correct 18 ms 1912 KB Output is correct
80 Correct 15 ms 1692 KB Output is correct
81 Correct 6 ms 764 KB Output is correct
82 Correct 5 ms 760 KB Output is correct
83 Correct 17 ms 1772 KB Output is correct
84 Correct 16 ms 1656 KB Output is correct
85 Correct 3 ms 504 KB Output is correct
86 Correct 5 ms 760 KB Output is correct
87 Correct 19 ms 1916 KB Output is correct
88 Correct 3 ms 504 KB Output is correct
89 Correct 15 ms 1908 KB Output is correct
90 Correct 46 ms 4852 KB Output is correct
91 Correct 45 ms 4728 KB Output is correct
92 Correct 12 ms 1528 KB Output is correct
93 Correct 15 ms 2036 KB Output is correct
94 Correct 49 ms 5236 KB Output is correct
95 Correct 12 ms 1528 KB Output is correct
96 Correct 26 ms 3056 KB Output is correct
97 Correct 71 ms 7668 KB Output is correct
98 Correct 86 ms 9076 KB Output is correct
99 Correct 76 ms 7412 KB Output is correct
100 Correct 22 ms 2680 KB Output is correct
101 Correct 2 ms 376 KB Output is correct
102 Correct 2 ms 376 KB Output is correct
103 Correct 25 ms 3084 KB Output is correct
104 Correct 2 ms 376 KB Output is correct
105 Correct 11 ms 760 KB Output is correct
106 Correct 7 ms 1012 KB Output is correct
107 Correct 5 ms 760 KB Output is correct
108 Correct 5 ms 760 KB Output is correct
109 Correct 14 ms 1908 KB Output is correct
110 Correct 15 ms 1908 KB Output is correct
111 Correct 25 ms 3056 KB Output is correct
112 Correct 2 ms 256 KB Output is correct
113 Correct 2 ms 376 KB Output is correct
114 Correct 70 ms 7696 KB Output is correct
115 Correct 4 ms 504 KB Output is correct
116 Correct 5 ms 760 KB Output is correct
117 Correct 31 ms 3448 KB Output is correct
118 Correct 33 ms 3700 KB Output is correct
119 Correct 90 ms 9032 KB Output is correct
120 Correct 85 ms 9076 KB Output is correct
121 Correct 84 ms 9076 KB Output is correct
122 Correct 85 ms 9076 KB Output is correct
123 Correct 25 ms 3056 KB Output is correct
124 Correct 77 ms 7668 KB Output is correct
125 Correct 94 ms 9076 KB Output is correct
126 Correct 91 ms 9236 KB Output is correct
127 Correct 68 ms 7448 KB Output is correct
128 Correct 21 ms 2680 KB Output is correct