Submission #416253

# Submission time Handle Problem Language Result Execution time Memory
416253 2021-06-02T08:36:09 Z idk321 Vision Program (IOI19_vision) C++17
58 / 100
65 ms 5596 KB
#include "vision.h"

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int h, w, k;

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

    int level = h * w;
    int hnorm = level;
    for (int i = 0; i < h; i++)
    {
        vector<int> cur;
        for (int j = 0; j < w; j++)
        {
            cur.push_back(i * w + j);
        }
        add_or(cur);
        level++;
    }
    int wnorm = level;
    for (int j = 0; j < w; j++)
    {
        vector<int> cur;
        for (int i = 0; i < h; i++)
        {
            cur.push_back(i * w + j);

        }
        add_or(cur);
        level++;

    }

    int xorh = level;
    vector<int> cur;
    for (int i = 0; i <h; i++)
    {
        cur.push_back(hnorm + i);
        add_xor(cur);
        level++;
    }
    cur.clear();
    int xorw = level;
    for (int j = 0; j < w; j++)
    {
        cur.push_back(wnorm + j);
        add_xor(cur);
        level++;
    }
    cur.clear();


    vector<int> toCheck;

    int notXorh = level;
    for (int i = 0; i< h; i++)
    {
        add_not(xorh + i);
        level++;
    }
    int notXorw = level;
    for (int i = 0; i  < w; i++)
    {
        add_not(xorw + i);
        level++;
    }

    if (k <= h)
    {
        for (int i = 0; i + k  <= h; i++)
        {
            toCheck.push_back(level);
            for (int j = 0; j < h; j++)
            {
                if (j >= i && j < i + k)cur.push_back(xorh + j);
                else cur.push_back(notXorh + j);
            }
            cur.push_back(xorw + w - 1);
            add_and(cur);
            level++;
            cur.clear();
        }
    }

    if (k <= w)
    {
        for (int i = 0; i + k <= w; i++)
        {
            toCheck.push_back(level);

            for (int j = 0; j < w; j++)
            {
                if (j >= i && j < i + k)cur.push_back(xorw + j);
                else cur.push_back(notXorw + j);
            }
            cur.push_back(xorh + h - 1);
            add_and(cur);
            level++;
            cur.clear();
        }
    }

    if (min(h, w) > 1 && k != 1)
    {
        vector<int> possH(h);
        vector<int> possW(w);

        for (int i = 1; i < h; i++)
        {
            int start = level;
            for (int j = 0; j + i <= h; j++)
            {

                for (int l = 0; l < h; l++)
                {
                    if (l >= j && l < j + i)cur.push_back(xorh + l);
                    else cur.push_back(notXorh + l);
                }
                add_and(cur);
                level++;
                cur.clear();
            }

            for (int j = start; j < level; j++)
            {
                cur.push_back(j);
            }
            possH[i] = level;
            add_or(cur);

            level++;

            cur.clear();
        }

        for (int i = 1; i < w; i++)
        {
            int start = level;
            for (int j = 0; j + i <= w; j++)
            {

                for (int l = 0; l < w; l++)
                {
                    if (l >= j && l < j + i) cur.push_back(xorw + l);
                    else cur.push_back(notXorw + l);
                }
                add_and(cur);
                level++;
                cur.clear();
            }

            for (int j = start; j < level; j++)
            {
                cur.push_back(j);
            }
            possW[i] = level;
            add_or(cur);

            level++;

            cur.clear();
        }

        int check1 = level;
        add_not(xorh + h - 1);
        level++;
        int check2 = level;
        add_not(xorw + w - 1);
        level++;

        for (int i = 1, j = k - 1; i < k && j >= 1; i++, j--)
        {
            if (i >= h || j >= w) continue;

            toCheck.push_back(level);
            cur.push_back(possH[i]);
            cur.push_back(possW[j]);
            cur.push_back(check1);
            cur.push_back(check2);
            add_and(cur);
            level++;
            cur.clear();
        }

    }





    add_or(toCheck);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 5 ms 588 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 5 ms 588 KB Output is correct
35 Correct 4 ms 588 KB Output is correct
36 Correct 4 ms 588 KB Output is correct
37 Correct 4 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 5 ms 588 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 5 ms 588 KB Output is correct
35 Correct 4 ms 588 KB Output is correct
36 Correct 4 ms 588 KB Output is correct
37 Correct 4 ms 588 KB Output is correct
38 Incorrect 7 ms 4548 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 716 KB Output is correct
2 Correct 5 ms 548 KB Output is correct
3 Correct 5 ms 548 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 8 ms 804 KB Output is correct
6 Correct 7 ms 716 KB Output is correct
7 Correct 5 ms 588 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 9 ms 840 KB Output is correct
10 Correct 6 ms 764 KB Output is correct
11 Correct 5 ms 588 KB Output is correct
12 Correct 5 ms 588 KB Output is correct
13 Correct 4 ms 528 KB Output is correct
14 Correct 4 ms 412 KB Output is correct
15 Correct 8 ms 808 KB Output is correct
16 Correct 7 ms 656 KB Output is correct
17 Correct 5 ms 588 KB Output is correct
18 Correct 5 ms 680 KB Output is correct
19 Correct 4 ms 588 KB Output is correct
20 Correct 3 ms 460 KB Output is correct
21 Correct 0 ms 296 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 65 ms 5596 KB Output is correct
5 Correct 62 ms 5436 KB Output is correct
6 Correct 61 ms 5440 KB Output is correct
7 Correct 63 ms 5436 KB Output is correct
8 Correct 5 ms 716 KB Output is correct
9 Incorrect 7 ms 4680 KB WA in grader: Too many inputs
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
4 Correct 5 ms 716 KB Output is correct
5 Correct 7 ms 716 KB Output is correct
6 Correct 9 ms 716 KB Output is correct
7 Correct 14 ms 1440 KB Output is correct
8 Correct 17 ms 1484 KB Output is correct
9 Correct 23 ms 2380 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 5 ms 588 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 5 ms 588 KB Output is correct
35 Correct 4 ms 588 KB Output is correct
36 Correct 4 ms 588 KB Output is correct
37 Correct 4 ms 588 KB Output is correct
38 Incorrect 7 ms 4548 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -