제출 #603777

#제출 시각아이디문제언어결과실행 시간메모리
603777jophyyjhVision Program (IOI19_vision)C++14
33 / 100
97 ms1104 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 (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 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...