답안 #362773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362773 2021-02-04T11:12:22 Z alextodoran Vision Program (IOI19_vision) C++17
12 / 100
54 ms 4904 KB
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

#include "vision.h"

using namespace std;

typedef long long ll;

const int NM_MAX = 202;

int add_and (vector <int> Ns);

int add_or (vector <int> Ns);

int add_xor (vector <int> Ns);

int add_not (int N);

int N, M;

int getKey (int a, int b)
{
    return (a - 1) * M + b - 1;
}

int diag1[NM_MAX * 2], diag2[NM_MAX * 2];

int dkdiag1[NM_MAX * 2], dkdiag2[NM_MAX * 2];
int dlessdiag1[NM_MAX * 2], dlessdiag2[NM_MAX * 2];

int diag1Equal, diag2Equal;
int diag1Less, diag2Less;

void construct_network (int n, int m, int k)
{
    N = n;
    M = m;
    vector <int> q;
    q.clear();
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            q.push_back(getKey(i, j));
    int alwaysFalse = add_xor(q);
    /// ====== DIAGONALS ======
    int curr;
    /// 5 6 7 8
    /// 4 5 6 7
    /// 3 4 5 6
    /// 2 3 4 5
    /// 1 2 3 4
    curr = 0;
    for(int is = n; is >= 1; is--)
    {
        curr++;
        q.clear();
        for(int i = is, j = 1; i <= n && j <= m; i++, j++)
            q.push_back(getKey(i, j));
        diag1[curr] = add_or(q);
    }
    for(int js = 2; js <= m; js++)
    {
        curr++;
        q.clear();
        for(int i = 1, j = js; i <= n && j <= m; i++, j++)
            q.push_back(getKey(i, j));
        diag1[curr] = add_or(q);
    }
    /// 1 2 3 4
    /// 2 3 4 5
    /// 3 4 5 6
    /// 4 5 6 7
    /// 5 6 7 8
    curr = 0;
    for(int js = 1; js <= m; js++)
    {
        curr++;
        q.clear();
        for(int i = 1, j = js; i <= n && j >= 1; i++, j--)
            q.push_back(getKey(i, j));
        diag2[curr] = add_or(q);
    }
    for(int is = 2; is <= n; is++)
    {
        curr++;
        q.clear();
        for(int i = is, j = m; i <= n && j >= 1; i++, j--)
            q.push_back(getKey(i, j));
        diag2[curr] = add_or(q);
    }
    /// ====== DISTANCE K DIAGONALS ======
    for(int d = 1; d + k <= n + m - 1; d++)
    {
        q.clear();
        q.push_back(diag1[d]);
        q.push_back(diag1[d + k]);
        dkdiag1[d] = add_and(q);
    }
    for(int d = 1; d + k <= n + m - 1; d++)
    {
        q.clear();
        q.push_back(diag2[d]);
        q.push_back(diag2[d + k]);
        dkdiag2[d] = add_and(q);
    }
    /// ====== DISTANCE LESS THAN K DIAGONALS ======
    for(int d = 1; d + k <= n + m - 1; d++)
    {
        q.clear();
        for(int l = 1; l < d; l++)
            q.push_back(diag1[l]);
        for(int r = d + k + 1; r <= n + m - 1; r++)
            q.push_back(diag1[r]);
        int aux;
        if(q.empty() == true)
            aux = alwaysFalse;
        else
            aux = add_and(q);
        dlessdiag1[d] = add_not(aux);
    }
    for(int d = 1; d + k <= n + m - 1; d++)
    {
        q.clear();
        for(int l = 1; l < d; l++)
            q.push_back(diag2[l]);
        for(int r = d + k + 1; r <= n + m - 1; r++)
            q.push_back(diag2[r]);
        int aux;
        if(q.empty() == true)
            aux = alwaysFalse;
        else
            aux = add_and(q);
        dlessdiag2[d] = add_not(aux);
    }
    /// ====== EQUAL ======
    q.clear();
    for(int d = 1; d + k <= n + m - 1; d++)
        q.push_back(dkdiag1[d]);
    diag1Equal = add_or(q);
    q.clear();
    for(int d = 1; d + k <= n + m - 1; d++)
        q.push_back(dkdiag2[d]);
    diag2Equal = add_or(q);
    /// ====== LESS ======
    q.clear();
    for(int d = 1; d + k <= n + m - 1; d++)
        q.push_back(dlessdiag1[d]);
    diag1Less = add_or(q);
    q.clear();
    for(int d = 1; d + k <= n + m - 1; d++)
        q.push_back(dlessdiag2[d]);
    diag2Less = add_or(q);
    /// ====== FINAL RESULT ======
    int case1, case2;
    q.clear();
    q.push_back(diag1Equal);
    q.push_back(diag2Less);
    case1 = add_and(q);
    q.clear();
    q.push_back(diag1Less);
    q.push_back(diag2Equal);
    case2 = add_and(q);
    int answer;
    q.clear();
    q.push_back(case1);
    q.push_back(case2);
    answer = add_or(q);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:170:9: warning: variable 'answer' set but not used [-Wunused-but-set-variable]
  170 |     int answer;
      |         ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 0 ms 364 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 0 ms 364 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 0 ms 364 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 0 ms 364 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1136 KB Output is correct
2 Correct 4 ms 492 KB Output is correct
3 Correct 4 ms 492 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 10 ms 1152 KB Output is correct
6 Correct 5 ms 748 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 10 ms 1004 KB Output is correct
10 Correct 8 ms 876 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 3 ms 492 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 13 ms 1132 KB Output is correct
16 Correct 9 ms 748 KB Output is correct
17 Correct 3 ms 620 KB Output is correct
18 Correct 4 ms 492 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 376 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 7 ms 748 KB Output is correct
4 Correct 4 ms 620 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 10 ms 1132 KB Output is correct
9 Correct 7 ms 876 KB Output is correct
10 Correct 5 ms 768 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 3 ms 492 KB Output is correct
13 Correct 10 ms 1132 KB Output is correct
14 Correct 5 ms 748 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 10 ms 1132 KB Output is correct
18 Correct 3 ms 492 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 39 ms 2844 KB Output is correct
21 Incorrect 25 ms 1948 KB on inputs (0, 0), (199, 99), expected 0, but computed 1
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 4904 KB on inputs (126, 120), (176, 169), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 0 ms 364 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -