답안 #294666

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
294666 2020-09-09T08:13:22 Z evpipis Vision Program (IOI19_vision) C++14
36 / 100
34 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))), temp.pb(equal_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))), temp.pb(equal_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);

    //printf("equal_sum = %d, less_sum = %d\n", equal_sum, less_sum);
    //printf("equal_dif = %d, less_dif = %d\n", equal_dif, less_dif);

    /// 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++){
      |                     ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Incorrect 1 ms 384 KB on inputs (0, 6), (1, 0), expected 0, but computed 1
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Incorrect 1 ms 384 KB on inputs (0, 6), (1, 0), expected 0, but computed 1
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Incorrect 1 ms 384 KB on inputs (0, 6), (1, 0), expected 0, but computed 1
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 416 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 6 ms 768 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 4 ms 640 KB Output is correct
7 Correct 6 ms 640 KB Output is correct
8 Correct 6 ms 768 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 640 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 6 ms 768 KB Output is correct
14 Correct 6 ms 768 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 4 ms 512 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
18 Correct 5 ms 640 KB Output is correct
19 Correct 6 ms 768 KB Output is correct
20 Correct 6 ms 768 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 4 ms 512 KB Output is correct
9 Incorrect 6 ms 640 KB on inputs (0, 0), (43, 2), expected 1, but computed 0
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 1272 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 16 ms 760 KB Output is correct
8 Correct 16 ms 768 KB Output is correct
9 Correct 34 ms 1272 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Incorrect 1 ms 384 KB on inputs (0, 6), (1, 0), expected 0, but computed 1
25 Halted 0 ms 0 KB -