Submission #731687

# Submission time Handle Problem Language Result Execution time Memory
731687 2023-04-27T19:15:27 Z danikoynov Vision Program (IOI19_vision) C++14
0 / 100
67 ms 7216 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

int H, W;

bool valid_cell(int x, int y)
{
    if (x >= 0 && x < H &&
        y >= 0 && y < W)
            return true;
    return false;
}

int left_diagonal_one(int sum)
{
    vector < int > cells;
    for (int x = 0; x < H; x ++)
    {
        int y = sum - x;
        if (valid_cell(x, y))
        {
            cells.push_back(x * W + y);
        }
    }
    /**cout << "query one " << endl;
    for (int v : cells)
    {
        cout << v / M << " " << v % M << endl;
    }*/

    return add_or(cells);
}

int left_diagonal_two(int sum)
{
    vector < int > cells;
    for (int x = 0; x < H; x ++)
    {
        int y = sum - x;
        if (valid_cell(x, y))
        {
            cells.push_back(x * W + y);
        }
    }

    int f1 = add_or(cells), f2 = add_xor(cells);
    int f3 = add_not(f2);
    vector < int > fin;
    fin.push_back(f1);
    fin.push_back(f3);
    return add_and(fin);
}

int right_diagonal_one(int diff)
{
    vector < int > cells;
    for (int x = 0; x < H; x ++)
    {
        int y = x + diff;
        if (valid_cell(x, y))
        {
            cells.push_back(x * W + y);
        }
    }
    /**cout << "query one " << endl;
    for (int v : cells)
    {
        cout << v / M << " " << v % M << endl;
    }*/

    return add_or(cells);
}

int right_diagonal_two(int diff)
{
    vector < int > cells;
    for (int x = 0; x < H; x ++)
    {
        int y = x + diff;
        if (valid_cell(x, y))
        {
            cells.push_back(x * W + y);
        }
    }

    int f1 = add_or(cells), f2 = add_xor(cells);
    int f3 = add_not(f2);
    vector < int > fin;
    fin.push_back(f1);
    fin.push_back(f3);
    return add_and(fin);
}

const int maxn = 1000;
int dig[2][2][maxn * 2];

void build_diagonals()
{
    for (int diff = W - 1; diff >= - H + 1; diff --)
    {
        dig[0][0][diff + maxn] = right_diagonal_one(diff);
        dig[1][0][diff + maxn] = right_diagonal_two(diff);
    }

    for (int sum = 0; sum <= H + W - 2; sum ++)
    {
        dig[0][1][sum + maxn] = left_diagonal_one(sum);
        dig[1][1][sum + maxn] = left_diagonal_two(sum);
    }
}

int get_right_gate(int dis)
{
    vector < int > con;
    for (int diff = W - 1; diff >= - H + 1; diff --)
    {
        vector < int > var, double_row;
        for (int cur = diff; cur >= - H + 1 && var.size() <= dis; cur --)
        {
            int v1 = dig[0][0][cur + maxn], v2 = dig[1][0][cur + maxn];
            double_row.push_back(v2);
            var.push_back(v1);
        }
        if (var.size() <= dis)
            break;

        int atl = add_or(var);
        int xort = add_xor(var);
        xort = add_not(xort);
        vector < int > mg;
        mg.push_back(atl);
        mg.push_back(xort);
        int comb = add_and(mg), is_double = add_or(double_row);
        mg.clear();
        mg.push_back(comb);
        mg.push_back(is_double);
        con.push_back(add_or(mg));
    }
    return add_or(con);
}

int get_left_gate(int dis)
{
    vector < int > con;
    for (int sum = 0; sum <= H + W - 2; sum ++)
    {
        vector < int > var, double_row;
        for (int cur = 0; cur <= H + W - 2 && var.size() <= dis; cur ++)
        {
            int v1 = dig[0][1][cur + maxn], v2 = dig[1][1][cur + maxn];
            double_row.push_back(v2);
            var.push_back(v1);
        }
        if (var.size() <= dis)
            break;

        int atl = add_or(var);
        int xort = add_xor(var);
        xort = add_not(xort);
        vector < int > mg;
        mg.push_back(atl);
        mg.push_back(xort);
        int comb = add_and(mg), is_double = add_or(double_row);
        mg.clear();
        mg.push_back(comb);
        mg.push_back(is_double);
        con.push_back(add_or(mg));
    }
    return add_or(con);
}
int check(int dis)
{
    int gate_right = get_right_gate(dis);

    int gate_left = get_left_gate(dis);

    vector < int > fin;
    fin.push_back(gate_left);

    fin.push_back(gate_right);
    return add_and(fin);
}
void construct_network(int h, int w, int K)
{
    H = h;
    W = w;


    build_diagonals();
    if (K == 1)
    {
        int is_less = check(K);
        return;
    }
    int is_above = check(K - 1);

    int is_less = check(K);

    int not_above = add_not(is_above);
    vector < int > fin;
    fin.push_back(not_above);
    fin.push_back(is_less);
    add_and(fin);

}

Compilation message

vision.cpp: In function 'int get_right_gate(int)':
vision.cpp:119:59: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  119 |         for (int cur = diff; cur >= - H + 1 && var.size() <= dis; cur --)
      |                                                ~~~~~~~~~~~^~~~~~
vision.cpp:125:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  125 |         if (var.size() <= dis)
      |             ~~~~~~~~~~~^~~~~~
vision.cpp: In function 'int get_left_gate(int)':
vision.cpp:149:58: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  149 |         for (int cur = 0; cur <= H + W - 2 && var.size() <= dis; cur ++)
      |                                               ~~~~~~~~~~~^~~~~~
vision.cpp:155:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  155 |         if (var.size() <= dis)
      |             ~~~~~~~~~~~^~~~~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:193:13: warning: unused variable 'is_less' [-Wunused-variable]
  193 |         int is_less = check(K);
      |             ^~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 596 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 8 ms 1108 KB Output is correct
5 Correct 13 ms 1324 KB Output is correct
6 Correct 12 ms 1452 KB Output is correct
7 Correct 12 ms 1532 KB Output is correct
8 Correct 5 ms 852 KB Output is correct
9 Correct 13 ms 1744 KB Output is correct
10 Correct 20 ms 2172 KB Output is correct
11 Correct 29 ms 2472 KB Output is correct
12 Correct 21 ms 2556 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 15 ms 1672 KB Output is correct
15 Correct 21 ms 2504 KB Output is correct
16 Correct 24 ms 2708 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 19 ms 2128 KB Output is correct
19 Correct 29 ms 2644 KB Output is correct
20 Correct 14 ms 1872 KB Output is correct
21 Correct 42 ms 4976 KB Output is correct
22 Correct 61 ms 6680 KB Output is correct
23 Correct 61 ms 7112 KB Output is correct
24 Correct 14 ms 1872 KB Output is correct
25 Correct 53 ms 5940 KB Output is correct
26 Correct 67 ms 7216 KB Output is correct
27 Correct 26 ms 3200 KB Output is correct
28 Incorrect 5 ms 2960 KB WA in grader: Too many instructions
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 3228 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -