답안 #362789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362789 2021-02-04T11:35:29 Z alextodoran Vision Program (IOI19_vision) C++17
100 / 100
54 ms 5032 KB
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

#include "vision.h"

using namespace std;

typedef long long ll;

const int NM_MAX = 202;

int add_and (vector <int> Ns);

int add_or (vector <int> Ns);

int add_xor (vector <int> Ns);

int add_not (int N);

int N, M;

int getKey (int a, int b)
{
    return (a - 1) * M + b - 1;
}

int diag1[NM_MAX * 2], diag2[NM_MAX * 2];

int dkdiag1[NM_MAX * 2], dkdiag2[NM_MAX * 2];
int dlessdiag1[NM_MAX * 2], dlessdiag2[NM_MAX * 2];

int diag1Equal, diag2Equal;
int diag1Less, diag2Less;

void construct_network (int n, int m, int k)
{
    N = n;
    M = m;
    vector <int> q;
    q.clear();
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            q.push_back(getKey(i, j));
    int alwaysFalse = add_xor(q);
    /// ====== DIAGONALS ======
    int curr;
    /// 5 6 7 8
    /// 4 5 6 7
    /// 3 4 5 6
    /// 2 3 4 5
    /// 1 2 3 4
    curr = 0;
    for(int is = n; is >= 1; is--)
    {
        curr++;
        q.clear();
        for(int i = is, j = 1; i <= n && j <= m; i++, j++)
            q.push_back(getKey(i, j));
        diag1[curr] = add_or(q);
    }
    for(int js = 2; js <= m; js++)
    {
        curr++;
        q.clear();
        for(int i = 1, j = js; i <= n && j <= m; i++, j++)
            q.push_back(getKey(i, j));
        diag1[curr] = add_or(q);
    }
    /// 1 2 3 4
    /// 2 3 4 5
    /// 3 4 5 6
    /// 4 5 6 7
    /// 5 6 7 8
    curr = 0;
    for(int js = 1; js <= m; js++)
    {
        curr++;
        q.clear();
        for(int i = 1, j = js; i <= n && j >= 1; i++, j--)
            q.push_back(getKey(i, j));
        diag2[curr] = add_or(q);
    }
    for(int is = 2; is <= n; is++)
    {
        curr++;
        q.clear();
        for(int i = is, j = m; i <= n && j >= 1; i++, j--)
            q.push_back(getKey(i, j));
        diag2[curr] = add_or(q);
    }
    /// ====== DISTANCE K DIAGONALS ======
    for(int d = 1; d + k <= n + m - 1; d++)
    {
        q.clear();
        q.push_back(diag1[d]);
        q.push_back(diag1[d + k]);
        dkdiag1[d] = add_and(q);
    }
    for(int d = 1; d + k <= n + m - 1; d++)
    {
        q.clear();
        q.push_back(diag2[d]);
        q.push_back(diag2[d + k]);
        dkdiag2[d] = add_and(q);
    }
    /// ====== DISTANCE LESS THAN K DIAGONALS ======
    for(int d = 1; d + k <= n + m - 1; d++)
    {
        q.clear();
        for(int l = 1; l < d; l++)
            q.push_back(diag1[l]);
        for(int r = d + k + 1; r <= n + m - 1; r++)
            q.push_back(diag1[r]);
        int aux;
        if(q.empty() == true)
            aux = alwaysFalse;
        else
            aux = add_or(q);
        dlessdiag1[d] = add_not(aux);
    }
    for(int d = 1; d + k <= n + m - 1; d++)
    {
        q.clear();
        for(int l = 1; l < d; l++)
            q.push_back(diag2[l]);
        for(int r = d + k + 1; r <= n + m - 1; r++)
            q.push_back(diag2[r]);
        int aux;
        if(q.empty() == true)
            aux = alwaysFalse;
        else
            aux = add_or(q);
        dlessdiag2[d] = add_not(aux);
    }
    /// ====== EQUAL ======
    q.clear();
    for(int d = 1; d + k <= n + m - 1; d++)
        q.push_back(dkdiag1[d]);
    diag1Equal = add_or(q);
    q.clear();
    for(int d = 1; d + k <= n + m - 1; d++)
        q.push_back(dkdiag2[d]);
    diag2Equal = add_or(q);
    /// ====== LESS ======
    q.clear();
    for(int d = 1; d + k <= n + m - 1; d++)
        q.push_back(dlessdiag1[d]);
    diag1Less = add_or(q);
    q.clear();
    for(int d = 1; d + k <= n + m - 1; d++)
        q.push_back(dlessdiag2[d]);
    diag2Less = add_or(q);
    /// ====== FINAL RESULT ======
    int case1, case2;
    q.clear();
    q.push_back(diag1Equal);
    q.push_back(diag2Less);
    case1 = add_and(q);
    q.clear();
    q.push_back(diag1Less);
    q.push_back(diag2Equal);
    case2 = add_and(q);
    int answer;
    q.clear();
    q.push_back(case1);
    q.push_back(case2);
    answer = add_or(q);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:170:9: warning: variable 'answer' set but not used [-Wunused-but-set-variable]
  170 |     int answer;
      |         ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 2 ms 492 KB Output is correct
34 Correct 2 ms 364 KB Output is correct
35 Correct 1 ms 492 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 2 ms 492 KB Output is correct
34 Correct 2 ms 364 KB Output is correct
35 Correct 1 ms 492 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 13 ms 1132 KB Output is correct
39 Correct 2 ms 492 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 8 ms 1024 KB Output is correct
42 Correct 3 ms 492 KB Output is correct
43 Correct 14 ms 1516 KB Output is correct
44 Correct 10 ms 1132 KB Output is correct
45 Correct 7 ms 876 KB Output is correct
46 Correct 5 ms 748 KB Output is correct
47 Correct 4 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1132 KB Output is correct
2 Correct 3 ms 620 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 10 ms 1132 KB Output is correct
6 Correct 6 ms 748 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 10 ms 1132 KB Output is correct
10 Correct 6 ms 748 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 10 ms 1132 KB Output is correct
16 Correct 6 ms 748 KB Output is correct
17 Correct 3 ms 620 KB Output is correct
18 Correct 3 ms 620 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 6 ms 748 KB Output is correct
4 Correct 4 ms 620 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 10 ms 1132 KB Output is correct
9 Correct 7 ms 876 KB Output is correct
10 Correct 5 ms 748 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 12 ms 1132 KB Output is correct
14 Correct 6 ms 748 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 13 ms 1132 KB Output is correct
18 Correct 3 ms 620 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 29 ms 2844 KB Output is correct
21 Correct 18 ms 1820 KB Output is correct
22 Correct 10 ms 1180 KB Output is correct
23 Correct 8 ms 924 KB Output is correct
24 Correct 29 ms 2844 KB Output is correct
25 Correct 18 ms 1436 KB Output is correct
26 Correct 8 ms 1052 KB Output is correct
27 Correct 54 ms 4904 KB Output is correct
28 Correct 37 ms 3496 KB Output is correct
29 Correct 25 ms 2472 KB Output is correct
30 Correct 20 ms 1832 KB Output is correct
31 Correct 15 ms 1576 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 5032 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 6 ms 748 KB Output is correct
4 Correct 13 ms 1132 KB Output is correct
5 Correct 10 ms 1132 KB Output is correct
6 Correct 10 ms 1132 KB Output is correct
7 Correct 29 ms 2844 KB Output is correct
8 Correct 30 ms 2844 KB Output is correct
9 Correct 54 ms 4904 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 2 ms 492 KB Output is correct
34 Correct 2 ms 364 KB Output is correct
35 Correct 1 ms 492 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 13 ms 1132 KB Output is correct
39 Correct 2 ms 492 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 8 ms 1024 KB Output is correct
42 Correct 3 ms 492 KB Output is correct
43 Correct 14 ms 1516 KB Output is correct
44 Correct 10 ms 1132 KB Output is correct
45 Correct 7 ms 876 KB Output is correct
46 Correct 5 ms 748 KB Output is correct
47 Correct 4 ms 620 KB Output is correct
48 Correct 10 ms 1132 KB Output is correct
49 Correct 3 ms 620 KB Output is correct
50 Correct 3 ms 492 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 10 ms 1132 KB Output is correct
53 Correct 6 ms 748 KB Output is correct
54 Correct 2 ms 492 KB Output is correct
55 Correct 1 ms 364 KB Output is correct
56 Correct 10 ms 1132 KB Output is correct
57 Correct 6 ms 748 KB Output is correct
58 Correct 3 ms 620 KB Output is correct
59 Correct 3 ms 620 KB Output is correct
60 Correct 2 ms 364 KB Output is correct
61 Correct 1 ms 364 KB Output is correct
62 Correct 10 ms 1132 KB Output is correct
63 Correct 6 ms 748 KB Output is correct
64 Correct 3 ms 620 KB Output is correct
65 Correct 3 ms 620 KB Output is correct
66 Correct 2 ms 364 KB Output is correct
67 Correct 1 ms 364 KB Output is correct
68 Correct 1 ms 364 KB Output is correct
69 Correct 1 ms 364 KB Output is correct
70 Correct 1 ms 364 KB Output is correct
71 Correct 1 ms 364 KB Output is correct
72 Correct 6 ms 748 KB Output is correct
73 Correct 4 ms 620 KB Output is correct
74 Correct 3 ms 492 KB Output is correct
75 Correct 3 ms 492 KB Output is correct
76 Correct 2 ms 492 KB Output is correct
77 Correct 10 ms 1132 KB Output is correct
78 Correct 7 ms 876 KB Output is correct
79 Correct 5 ms 748 KB Output is correct
80 Correct 3 ms 620 KB Output is correct
81 Correct 3 ms 512 KB Output is correct
82 Correct 12 ms 1132 KB Output is correct
83 Correct 6 ms 748 KB Output is correct
84 Correct 2 ms 492 KB Output is correct
85 Correct 1 ms 364 KB Output is correct
86 Correct 13 ms 1132 KB Output is correct
87 Correct 3 ms 620 KB Output is correct
88 Correct 1 ms 364 KB Output is correct
89 Correct 29 ms 2844 KB Output is correct
90 Correct 18 ms 1820 KB Output is correct
91 Correct 10 ms 1180 KB Output is correct
92 Correct 8 ms 924 KB Output is correct
93 Correct 29 ms 2844 KB Output is correct
94 Correct 18 ms 1436 KB Output is correct
95 Correct 8 ms 1052 KB Output is correct
96 Correct 54 ms 4904 KB Output is correct
97 Correct 37 ms 3496 KB Output is correct
98 Correct 25 ms 2472 KB Output is correct
99 Correct 20 ms 1832 KB Output is correct
100 Correct 15 ms 1576 KB Output is correct
101 Correct 1 ms 384 KB Output is correct
102 Correct 1 ms 364 KB Output is correct
103 Correct 53 ms 5032 KB Output is correct
104 Correct 1 ms 364 KB Output is correct
105 Correct 6 ms 748 KB Output is correct
106 Correct 13 ms 1132 KB Output is correct
107 Correct 10 ms 1132 KB Output is correct
108 Correct 10 ms 1132 KB Output is correct
109 Correct 29 ms 2844 KB Output is correct
110 Correct 30 ms 2844 KB Output is correct
111 Correct 54 ms 4904 KB Output is correct
112 Correct 1 ms 364 KB Output is correct
113 Correct 1 ms 364 KB Output is correct
114 Correct 51 ms 3496 KB Output is correct
115 Correct 1 ms 380 KB Output is correct
116 Correct 10 ms 1260 KB Output is correct
117 Correct 9 ms 1052 KB Output is correct
118 Correct 23 ms 2332 KB Output is correct
119 Correct 25 ms 2480 KB Output is correct
120 Correct 31 ms 2352 KB Output is correct
121 Correct 25 ms 2480 KB Output is correct
122 Correct 25 ms 2608 KB Output is correct
123 Correct 53 ms 5032 KB Output is correct
124 Correct 37 ms 3496 KB Output is correct
125 Correct 25 ms 2472 KB Output is correct
126 Correct 25 ms 2472 KB Output is correct
127 Correct 18 ms 1832 KB Output is correct
128 Correct 15 ms 1576 KB Output is correct