Submission #294655

# Submission time Handle Problem Language Result Execution time Memory
294655 2020-09-09T08:05:03 Z evpipis Vision Program (IOI19_vision) C++14
0 / 100
35 ms 1272 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
typedef vector<int> vi;

const int len = 205;
int n, m, k;

bool exist(int i, int j){
    return (0 <= i && i < n && 0 <= j && j < m);
}

int match(int i, int j){
    return i*m + j;
}

vi diag_sum(int con){
    vi res;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (i+j == con) res.pb(match(i, j));
    return res;
}

vi diag_dif(int con){
    vi res;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (i-j == con) res.pb(match(i, j));
    return res;
}

void construct_network(int H, int W, int K) {
    n = H, m = W, k = K;
    vi temp, sum, dif;

    /// precompute everything
    // compute sum[], dif[]
    for (int con = 0; con <= n+m-2; con++)
        sum.pb(add_xor(diag_sum(con)));

    for (int con = -m+1; con <= n-1; con++)
        dif.pb(add_xor(diag_dif(con)));

    // compute equal_sum, equal_dif
    temp.clear();
    for (int i = 0; i+k < sum.size(); i++)
        temp.pb(add_and({sum[i], sum[i+k]}));
    int equal_sum = add_or(temp);

    temp.clear();
    for (int i = 0; i+k < dif.size(); i++)
        temp.pb(add_and({dif[i], dif[i+k]}));
    int equal_dif = add_or(temp);

    // compute less_sum, less_dif
    temp.clear();
    temp.pb(add_not(add_or(sum)));
    for (int i = 0; i < sum.size(); i++){
        vi temp2;
        for (int j = i+1; j < min(i+k, (int)sum.size()); j++)
            temp2.pb(sum[j]);
        if (!temp2.empty())
            temp.pb(add_and({sum[i], add_or(temp2)}));
    }
    int less_sum = add_or(temp);

    temp.clear();
    temp.pb(add_not(add_or(dif)));
    for (int i = 0; i < dif.size(); i++){
        vi temp2;
        for (int j = i+1; j < min(i+k, (int)dif.size()); j++)
            temp2.pb(dif[j]);
        if (!temp2.empty())
            temp.pb(add_and({sum[i], add_or(temp2)}));
    }
    int less_dif = add_or(temp);

    /// find ans:)
    add_or({add_and({less_sum, equal_dif}), add_and({less_dif, equal_sum})});
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:49:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for (int i = 0; i+k < sum.size(); i++)
      |                     ~~~~^~~~~~~~~~~~
vision.cpp:54:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int i = 0; i+k < dif.size(); i++)
      |                     ~~~~^~~~~~~~~~~~
vision.cpp:61:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for (int i = 0; i < sum.size(); i++){
      |                     ~~^~~~~~~~~~~~
vision.cpp:72:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     for (int i = 0; i < dif.size(); i++){
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 1272 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 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -