Submission #416250

# Submission time Handle Problem Language Result Execution time Memory
416250 2021-06-02T08:28:56 Z idk321 Vision Program (IOI19_vision) C++17
Compilation error
0 ms 0 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 j = 0; j + k <= w; j++)
        {
            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();
        }
    }



    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);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:99:26: error: 'i' was not declared in this scope
   99 |                 if (j >= i && j < i + k)cur.push_back(xorw + j);
      |                          ^