이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* 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 (i think. i haven't checked)
* Number of reads: 6HW
* Implementation 1 (Solves [S1-3], [S5], [S6-7])
*/
#include <bits/stdc++.h>
#include "vision.h"
typedef std::vector<int> vec;
void construct_network(int h, int w, int K) {
if (K == 1 || h * w <= 900) {
vec ands;
for (int i1 = 0; i1 < h; i1++) {
for (int j1 = 0; j1 < w; j1++) {
for (int i2 = i1; i2 < h; i2++) {
for (int j2 = 0; j2 < w; j2++) {
if (std::abs(i2 - i1) + std::abs(j2 - j1) == K)
ands.push_back(add_and({i1 * w + j1, i2 * w + j2}));
}
}
}
}
add_or(ands);
} else { // [S6]
vec ands;
for (int i = std::min(h - 1, K); i >= 0; i--) {
int j = K - i;
if (j >= w)
break;
ands.push_back(add_and({0, i * w + j}));
}
add_or(ands);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |