Submission #1069899

# Submission time Handle Problem Language Result Execution time Memory
1069899 2024-08-22T09:48:53 Z andrei_iorgulescu Vision Program (IOI19_vision) C++14
100 / 100
31 ms 3512 KB
#include <bits/stdc++.h>
#include "vision.h"
#warning That's not FB, that's my FB

using namespace std;

int h, w, k;
int sure_0, sure_1;

int cond1()
{
    if (k >= h - 1)
    {
        return add_or({sure_1});
    }
    vector<int> vlin(h);
    for (int i = 0; i < h; i++)
    {
        vector<int> ps;
        for (int j = 0; j < w; j++)
            ps.push_back(w * i + j);
        vlin[i] = add_or(ps);
    }
    vector<int> cns;
    for (int i = 0; i + 1 < h; i++)
    {
        vector<int> ur;
        for (int j = 1; j <= k; j++)
            if (i + j < h)
                ur.push_back(vlin[i + j]);
        int pp = add_or(ur);
        cns.push_back(add_and({vlin[i], pp}));
    }
    int rr = add_or(cns);
    cns.clear();
    for (int i = 0; i < h; i++)
        cns.push_back(vlin[i]);
    int rrr = add_xor(cns);
    int rrrr = add_or({rr,rrr});
    return rrrr;
}

int cond2()
{
    if (k >= w - 1)
    {
        return add_or({sure_1});
    }
    vector<int> vlin(w);
    for (int j = 0; j < w; j++)
    {
        vector<int> ps;
        for (int i = 0; i < h; i++)
            ps.push_back(w * i + j);
        vlin[j] = add_or(ps);
    }
    vector<int> cns;
    for (int i = 0; i + 1 < w; i++)
    {
        vector<int> ur;
        for (int j = 1; j <= k; j++)
            if (i + j < w)
                ur.push_back(vlin[i + j]);
        int pp = add_or(ur);
        cns.push_back(add_and({vlin[i], pp}));
    }
    int rr = add_or(cns);
    cns.clear();
    for (int i = 0; i < w; i++)
        cns.push_back(vlin[i]);
    int rrr = add_xor(cns);
    int rrrr = add_or({rr,rrr});
    return rrrr;
}

int cond3()
{
    vector<vector<int>> diag(h + w - 1);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            diag[i + j].push_back(w * i + j);
        }
    }
    vector<int> cdiag(h + w - 1);
    for (int i = 0; i < h + w - 1; i++)
        cdiag[i] = add_or(diag[i]);
    vector<int> ff;
    for (int i = 0; i + k < h + w - 1; i++)
        ff.push_back(add_and({cdiag[i], cdiag[i + k]}));
    int lmao = add_or(ff);
    return lmao;
}

int cond4()
{
    int ofs = w - 1;
    vector<vector<int>> diag(h + w - 1);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            diag[i - j + ofs].push_back(w * i + j);
        }
    }
    vector<int> cdiag(h + w - 1);
    for (int i = 0; i < h + w - 1; i++)
        cdiag[i] = add_or(diag[i]);
    vector<int> ff;
    for (int i = 0; i + k < h + w - 1; i++)
        ff.push_back(add_and({cdiag[i], cdiag[i + k]}));
    int lmao = add_or(ff);
    return lmao;
}

void construct_network(int H, int W, int K)
{
    if (H * W == 2)
    {
        if (K == 1)
        {
            add_or({0});
            return;
        }
        else
        {
            add_not(0);
            return;
        }
    }
    vector<int> tot;
    for (int i = 0; i < H * W; i++)
        tot.push_back(i);
    sure_0 = add_and(tot);
    sure_1 = add_or(tot);
    h = H, w = W, k = K;
    int pos1 = cond1();
    int pos2 = cond2();
    int pos3 = cond3();
    int pos4 = cond4();
    int pos5 = add_or({pos3, pos4});
    int fin = add_and({pos1, pos2, pos5});
    //cout << pos1 << ' ' << pos2 << ' ' << pos3 << ' ' << pos4 << ' ' << pos5 << endl;
    //cout << "ye" << endl;
    return;
}

/**
Conditie de echivalenta:
C1: delta_lin <= k
C2: delta_col <= k
C3: delta_dp = k sau C4: delta_ds = k

Practic verific C1, C2, C3, C4 si pun (C1 & C2 & (C3 | C4))


**/

Compilation message

vision.cpp:3:2: warning: #warning That's not FB, that's my FB [-Wcpp]
    3 | #warning That's not FB, that's my FB
      |  ^~~~~~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:143:9: warning: unused variable 'fin' [-Wunused-variable]
  143 |     int fin = add_and({pos1, pos2, pos5});
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 436 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 436 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 436 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 436 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 5 ms 1116 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 5 ms 944 KB Output is correct
44 Correct 5 ms 1112 KB Output is correct
45 Correct 3 ms 860 KB Output is correct
46 Correct 3 ms 860 KB Output is correct
47 Correct 3 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 684 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 1 ms 436 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 600 KB Output is correct
19 Correct 2 ms 600 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 696 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 3 ms 688 KB Output is correct
9 Correct 3 ms 860 KB Output is correct
10 Correct 3 ms 860 KB Output is correct
11 Correct 4 ms 856 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 612 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 11 ms 1804 KB Output is correct
21 Correct 8 ms 1548 KB Output is correct
22 Correct 5 ms 1292 KB Output is correct
23 Correct 6 ms 1292 KB Output is correct
24 Correct 8 ms 1804 KB Output is correct
25 Correct 7 ms 1800 KB Output is correct
26 Correct 5 ms 1544 KB Output is correct
27 Correct 30 ms 3224 KB Output is correct
28 Correct 19 ms 3476 KB Output is correct
29 Correct 11 ms 2200 KB Output is correct
30 Correct 11 ms 2196 KB Output is correct
31 Correct 9 ms 2200 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 3224 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 7 ms 1848 KB Output is correct
8 Correct 9 ms 1804 KB Output is correct
9 Correct 29 ms 3228 KB Output is correct
10 Correct 0 ms 512 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 436 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 5 ms 1116 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 5 ms 944 KB Output is correct
44 Correct 5 ms 1112 KB Output is correct
45 Correct 3 ms 860 KB Output is correct
46 Correct 3 ms 860 KB Output is correct
47 Correct 3 ms 860 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 1 ms 684 KB Output is correct
50 Correct 2 ms 604 KB Output is correct
51 Correct 1 ms 436 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 1 ms 604 KB Output is correct
54 Correct 2 ms 604 KB Output is correct
55 Correct 2 ms 604 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 604 KB Output is correct
58 Correct 1 ms 604 KB Output is correct
59 Correct 1 ms 604 KB Output is correct
60 Correct 2 ms 604 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 1 ms 604 KB Output is correct
64 Correct 2 ms 600 KB Output is correct
65 Correct 2 ms 600 KB Output is correct
66 Correct 2 ms 600 KB Output is correct
67 Correct 1 ms 344 KB Output is correct
68 Correct 1 ms 344 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 2 ms 604 KB Output is correct
73 Correct 2 ms 604 KB Output is correct
74 Correct 2 ms 604 KB Output is correct
75 Correct 2 ms 696 KB Output is correct
76 Correct 1 ms 348 KB Output is correct
77 Correct 3 ms 688 KB Output is correct
78 Correct 3 ms 860 KB Output is correct
79 Correct 3 ms 860 KB Output is correct
80 Correct 4 ms 856 KB Output is correct
81 Correct 2 ms 604 KB Output is correct
82 Correct 1 ms 348 KB Output is correct
83 Correct 1 ms 612 KB Output is correct
84 Correct 2 ms 604 KB Output is correct
85 Correct 1 ms 348 KB Output is correct
86 Correct 1 ms 348 KB Output is correct
87 Correct 2 ms 604 KB Output is correct
88 Correct 0 ms 348 KB Output is correct
89 Correct 11 ms 1804 KB Output is correct
90 Correct 8 ms 1548 KB Output is correct
91 Correct 5 ms 1292 KB Output is correct
92 Correct 6 ms 1292 KB Output is correct
93 Correct 8 ms 1804 KB Output is correct
94 Correct 7 ms 1800 KB Output is correct
95 Correct 5 ms 1544 KB Output is correct
96 Correct 30 ms 3224 KB Output is correct
97 Correct 19 ms 3476 KB Output is correct
98 Correct 11 ms 2200 KB Output is correct
99 Correct 11 ms 2196 KB Output is correct
100 Correct 9 ms 2200 KB Output is correct
101 Correct 0 ms 344 KB Output is correct
102 Correct 0 ms 344 KB Output is correct
103 Correct 31 ms 3224 KB Output is correct
104 Correct 0 ms 344 KB Output is correct
105 Correct 3 ms 604 KB Output is correct
106 Correct 2 ms 860 KB Output is correct
107 Correct 1 ms 436 KB Output is correct
108 Correct 1 ms 348 KB Output is correct
109 Correct 7 ms 1848 KB Output is correct
110 Correct 9 ms 1804 KB Output is correct
111 Correct 29 ms 3228 KB Output is correct
112 Correct 0 ms 512 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 17 ms 3480 KB Output is correct
115 Correct 3 ms 604 KB Output is correct
116 Correct 1 ms 348 KB Output is correct
117 Correct 5 ms 1292 KB Output is correct
118 Correct 16 ms 1932 KB Output is correct
119 Correct 10 ms 2176 KB Output is correct
120 Correct 11 ms 2248 KB Output is correct
121 Correct 10 ms 2204 KB Output is correct
122 Correct 9 ms 2228 KB Output is correct
123 Correct 15 ms 3224 KB Output is correct
124 Correct 16 ms 3512 KB Output is correct
125 Correct 10 ms 2200 KB Output is correct
126 Correct 10 ms 2156 KB Output is correct
127 Correct 11 ms 2128 KB Output is correct
128 Correct 11 ms 2200 KB Output is correct