Submission #603829

#TimeUsernameProblemLanguageResultExecution timeMemory
603829jophyyjhVision Program (IOI19_vision)C++14
52 / 100
901 ms2044 KiB
/**
 * Wow. Idk how to express my shock when i saw that interactive problems can be like
 * this! So we basically have to write a program that outputs the correct 0/1 across
 * all images. First thought: we can't do compare each pair of rows, this takes about
 * 19900 (>10000) calls.
 * We don't have "for" or "if" statements... Hmm. I don't wanna do int addition /
 * subtraction using logic gates too... Well, in general we don't have much calls
 * available, so perhaps in a lot of calls the num of input isn't small. Nah...
 * 
 * I'd like to note down my final thought. Suppose that c_1, c_2, ..., c_m are 0/1
 * bits representing whether column i has a black cell. Let's put away the case of
 * only one 1. Let d_i := c_1 ^ c_2 ^ ... ^ c_i, so the number of 1s in (d_i) is 
 * the horizontal dist. Similarly we can do this for the vertical direction, then 
 * it suffices to count the num of 1s in some cells and check if it's K.
 * Unfortunately, the only sol i have is to do a dp which requires an additional
 * K(H+W) cells. Too much... (I'll submit a brute-force version in impl1)
 * 
 * This think this is a problem where scoring partials is easy, but getting full is
 * hard.
 * 
 * Number of calls: 2HW
 * Number of reads: idk, but too many
 * Implementation 1         (Solves [S1-3], [S5], [S6])
*/

#include <bits/stdc++.h>
#include "vision.h"

typedef std::vector<int>    vec;


void construct_network(int h, int w, int K) {
    if (h * w <= 900) {
        vec list;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                vec ors;
                for (int delta_i = -K; delta_i <= K; delta_i++) {
                    std::cerr << "[debug] " << i << ' ' << j << ' ' << delta_i << std::endl;
                    int delta_j = K - std::abs(delta_i);
                    if (i + delta_i >= 0 && i + delta_i < h
                            && j + delta_j >= 0 && j + delta_j < w) {
                        ors.push_back((i + delta_i) * w + (j + delta_j));
                    }
                    if (delta_j > 0 && i + delta_i >= 0 && i + delta_i < h
                            && j - delta_j >= 0 && j - delta_j < w) {
                        ors.push_back((i + delta_i) * w + (j - delta_j));
                    }
                }
                if (!ors.empty())
                    list.push_back(add_and({add_or(ors), i * w + j}));
            }
        }
        add_or(list);
    } else {    // [S6]
        vec ors;
        for (int i = std::min(h - 1, K); i >= 0; i--) {
            int j = K - i;
            if (j >= w)
                break;
            ors.push_back(i * w + j);
        }
        add_or(ors);
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...