답안 #603829

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
603829 2022-07-24T12:11:33 Z jophyyjh Vision Program (IOI19_vision) C++14
52 / 100
901 ms 2044 KB
/**
 * 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);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 11 ms 304 KB Output is correct
23 Correct 3 ms 212 KB Output is correct
24 Correct 10 ms 304 KB Output is correct
25 Correct 16 ms 300 KB Output is correct
26 Correct 24 ms 336 KB Output is correct
27 Correct 30 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 11 ms 304 KB Output is correct
23 Correct 3 ms 212 KB Output is correct
24 Correct 10 ms 304 KB Output is correct
25 Correct 16 ms 300 KB Output is correct
26 Correct 24 ms 336 KB Output is correct
27 Correct 30 ms 332 KB Output is correct
28 Correct 258 ms 1004 KB Output is correct
29 Correct 7 ms 212 KB Output is correct
30 Correct 7 ms 296 KB Output is correct
31 Correct 301 ms 788 KB Output is correct
32 Correct 19 ms 380 KB Output is correct
33 Correct 23 ms 460 KB Output is correct
34 Correct 255 ms 1028 KB Output is correct
35 Correct 421 ms 1516 KB Output is correct
36 Correct 657 ms 1676 KB Output is correct
37 Correct 901 ms 2044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 11 ms 304 KB Output is correct
23 Correct 3 ms 212 KB Output is correct
24 Correct 10 ms 304 KB Output is correct
25 Correct 16 ms 300 KB Output is correct
26 Correct 24 ms 336 KB Output is correct
27 Correct 30 ms 332 KB Output is correct
28 Correct 258 ms 1004 KB Output is correct
29 Correct 7 ms 212 KB Output is correct
30 Correct 7 ms 296 KB Output is correct
31 Correct 301 ms 788 KB Output is correct
32 Correct 19 ms 380 KB Output is correct
33 Correct 23 ms 460 KB Output is correct
34 Correct 255 ms 1028 KB Output is correct
35 Correct 421 ms 1516 KB Output is correct
36 Correct 657 ms 1676 KB Output is correct
37 Correct 901 ms 2044 KB Output is correct
38 Incorrect 1 ms 212 KB on inputs (8, 61), (22, 97), expected 1, but computed 0
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 340 KB Output is correct
2 Correct 358 ms 892 KB Output is correct
3 Correct 316 ms 972 KB Output is correct
4 Correct 669 ms 1640 KB Output is correct
5 Correct 9 ms 340 KB Output is correct
6 Correct 217 ms 740 KB Output is correct
7 Correct 456 ms 1104 KB Output is correct
8 Correct 646 ms 1696 KB Output is correct
9 Correct 6 ms 340 KB Output is correct
10 Correct 179 ms 580 KB Output is correct
11 Correct 330 ms 1084 KB Output is correct
12 Correct 368 ms 968 KB Output is correct
13 Correct 492 ms 1232 KB Output is correct
14 Correct 684 ms 1628 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 165 ms 616 KB Output is correct
17 Correct 334 ms 960 KB Output is correct
18 Correct 347 ms 988 KB Output is correct
19 Correct 511 ms 1228 KB Output is correct
20 Correct 670 ms 1652 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 7 ms 336 KB Output is correct
14 Correct 198 ms 692 KB Output is correct
15 Correct 536 ms 1236 KB Output is correct
16 Correct 671 ms 1684 KB Output is correct
17 Correct 5 ms 340 KB Output is correct
18 Correct 331 ms 932 KB Output is correct
19 Correct 687 ms 1644 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 300 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 11 ms 304 KB Output is correct
23 Correct 3 ms 212 KB Output is correct
24 Correct 10 ms 304 KB Output is correct
25 Correct 16 ms 300 KB Output is correct
26 Correct 24 ms 336 KB Output is correct
27 Correct 30 ms 332 KB Output is correct
28 Correct 258 ms 1004 KB Output is correct
29 Correct 7 ms 212 KB Output is correct
30 Correct 7 ms 296 KB Output is correct
31 Correct 301 ms 788 KB Output is correct
32 Correct 19 ms 380 KB Output is correct
33 Correct 23 ms 460 KB Output is correct
34 Correct 255 ms 1028 KB Output is correct
35 Correct 421 ms 1516 KB Output is correct
36 Correct 657 ms 1676 KB Output is correct
37 Correct 901 ms 2044 KB Output is correct
38 Incorrect 1 ms 212 KB on inputs (8, 61), (22, 97), expected 1, but computed 0
39 Halted 0 ms 0 KB -