답안 #284067

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284067 2020-08-26T16:14:11 Z kartel Vision Program (IOI19_vision) C++14
59 / 100
26 ms 3188 KB
#include <bits/stdc++.h>
//#include "grader.cpp"
#include "vision.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define pb push_back
#define N +205
#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e9)
#define el '\n'
#define Max_A int(1e9)
//#define el endl
#define pii pair <int, int>
#define piii pair <int, pair <int, int> >
#define psi pair <string, int>
#define err ld(1e-9)
#define Max_S int(3e6)
#define last(x) (x).back()
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define arr_all(x, n) (x + 1), (x + 1 + n)
#define vi vector<int>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;

int i, j;
int diag_r[2][N][N];
int diag_l[2][N][N];
int diag_R[N][2];
int diag_L[N][2];

void construct_network(int n, int m, int k)
{
    vi vc;
    int num = n * m;
    for (i = 0; i < n; i++)
      {
          int x = i;

          if (i == m)
            break;

          vc.pb(x * m + x);
      }

    add_or(vc);
//    cerr << num << el;

    diag_r[0][0][0] = num++;
    diag_R[n - 1][0] = num - 1;

    for (i = 1; i < n; i++)
    {
        int x = i;
        int y = 0;

        vi vc;
        vc.clear();

        for (; x < n && y < m; x++, y++)
            vc.pb(x * m + y);

        add_or(vc);

//        cerr << num << el;

        diag_r[0][i][0] = num++;
        diag_R[n - i - 1][0] = num - 1;
    }

    for (j = 1; j < m; j++)
    {
        int x = 0;
        int y = j;

        vi vc;
        vc.clear();

        for (; x < n && y < m; x++, y++)
            vc.pb(x * m + y);

        add_or(vc);
//        cerr << num << el;

        diag_r[0][0][j] = num++;
        diag_R[n + j - 1][0] = num - 1;
    }

    //------------------

//    cout << el;

    int y = m - 1;
    vc.clear();

    for (i = 0; i < n && y >= 0; i++)
      {
          int x = i;

          vc.pb(x * m + y);
          y--;
      }

    add_or(vc);
//    cerr << num << el;

    diag_l[0][0][m - 1] = num++;
    diag_L[n - 1][0] = num - 1;

    for (i = 1; i < n; i++)
    {
        int x = i;
        int y = m - 1;

        vi vc;
        vc.clear();

        for (; x < n && y >= 0; x++, y--)
            vc.pb(x * m + y);

        add_or(vc);
//        cerr << num << el;

        diag_l[0][i][m - 1] = num++;
        diag_L[n - i - 1][0] = num - 1;
    }

    for (j = 0; j < m - 1; j++)
    {
        int x = 0;
        int y = j;

        vi vc;
        vc.clear();

        for (; x < n && y >= 0; x++, y--)
            vc.pb(x * m + y);

        add_or(vc);
//        cerr << num << el;

        diag_l[0][0][j] = num++;
        diag_L[n + m - j - 2][0] = num - 1;
    }

    //-----------------------------------
//    cout << el;
    vc.clear();

    for (i = 0; i < n; i++)
      {
          int x = i;

          if (i == m)
            break;

          vc.pb(x * m + x);
      }
    vc.pb(diag_r[0][0][0]);

    add_xor(vc);
//    cerr << num << el;

    diag_r[1][0][0] = num++;
    diag_R[n - 1][1] = num - 1;

    for (i = 1; i < n; i++)
    {
        int x = i;
        int y = 0;

        vi vc;
        vc.clear();

        for (; x < n && y < m; x++, y++)
            vc.pb(x * m + y);

        vc.pb(diag_r[0][i][0]);

        add_xor(vc);
//        cerr << num << el;

        diag_r[1][i][0] = num++;
        diag_R[n - i - 1][1] = num - 1;
    }

    for (j = 1; j < m; j++)
    {
        int x = 0;
        int y = j;

        vi vc;
        vc.clear();

        for (; x < n && y < m; x++, y++)
            vc.pb(x * m + y);

        vc.pb(diag_r[0][0][j]);

        add_xor(vc);
//        cerr << num << el;

        diag_r[1][0][j] = num++;
        diag_R[n + j - 1][1] = num - 1;
    }

    //--------------------------------
    vc.clear();

//    cout << el;

    y = m - 1;

    for (i = 0; i < n && y >= 0; i++)
      {
          int x = i;

          vc.pb(x * m + y);
          y--;
      }

    vc.pb(diag_l[0][0][m - 1]);

    add_xor(vc);
//    cerr << num << el;

    diag_l[1][0][m - 1] = num++;
    diag_L[n - 1][1] = num - 1;

    for (i = 1; i < n; i++)
    {
        int x = i;
        int y = m - 1;

        vi vc;
        vc.clear();

        for (; x < n && y >= 0; x++, y--)
            vc.pb(x * m + y);

        vc.pb(diag_l[0][i][m - 1]);

        add_xor(vc);
//        cerr << num << el;

        diag_l[1][i][m - 1] = num++;
        diag_L[n - i - 1][1] = num - 1;
    }

    for (j = 0; j < m - 1; j++)
    {
        int x = 0;
        int y = j;

        vi vc;
        vc.clear();

        for (; x < n && y >= 0; x++, y--)
            vc.pb(x * m + y);

        vc.pb(diag_l[0][0][j]);

        add_xor(vc);
//        cerr << num << el;

        diag_l[1][0][j] = num++;
        diag_L[n + m - j - 2][1] = num - 1;
    }

    vi vec;
//    cout << el;

    for (i = 0; i < n + m - 1 - k; i++)
    {
        vi vc, vec1;

        for (j = i; j <= i + k; j++)
        {
            vc.pb(diag_L[j][0]);
            vc.pb(diag_L[j][1]);
            vec1.pb(diag_L[j][0]);
            vec1.pb(diag_L[j][1]);
        }

        add_xor(vc);
//        cerr << num << el;
        add_not(num++);
        int hv = num++;
        add_or(vc);
        vec1.clear();
        vec1.pb(num++);
        vec1.pb(hv);
        add_and(vec1);
//        cerr << num << el;

        vec.pb(num++);
    }

    add_or(vec);
//    cerr << num << el;

    int one = num++;

    vec.clear();
    cout << el;

    for (i = 0; i < n + m - 1 - k; i++)
    {
        vi vc, vec1;
        for (j = i; j <= i + k; j++)
        {
//            cerr << diag_R[j][0] << " " << diag_R[j][1] << el;
            vc.pb(diag_R[j][0]);
            vc.pb(diag_R[j][1]);
        }

        add_xor(vc);
//        cerr << num << el;
        add_not(num++);
        int hv = num++;
        add_or(vc);
        vec1.clear();
        vec1.pb(num++);
        vec1.pb(hv);
        add_and(vec1);

        vec.pb(num++);
    }

    add_or(vec);
//    cerr << num << el;

    int two = num++;
    vec.clear();
    vec.pb(two);
    vec.pb(one);

    add_and(vec);
//    cerr << num << el << el;

    int fiv = num++;

    vec.clear();

    for (i = 0; i < n + m - 1 - k + 1; i++)
    {
        vi vc, vec1;

        for (j = i; j <= i + k - 1; j++)
        {
            vc.pb(diag_L[j][0]);
            vc.pb(diag_L[j][1]);
        }

        add_xor(vc);
//        cerr << num << el;
        add_not(num++);
        int hv = num++;
        add_or(vc);
        vec1.clear();
        vec1.pb(num++);
        vec1.pb(hv);
        add_and(vec1);

        vec.pb(num++);
    }

    add_or(vec);
//    cerr << num << el << el;

    one = num++;

    vec.clear();

    for (i = 0; i < n + m - 1 - k + 1; i++)
    {
        vi vc, vec1;
        for (j = i; j <= i + k - 1; j++)
        {
            vc.pb(diag_R[j][0]);
            vc.pb(diag_R[j][1]);
        }

        add_xor(vc);
//        cerr << num << el;
        add_not(num++);
        int hv = num++;
        add_or(vc);
        vec1.clear();
        vec1.pb(num++);
        vec1.pb(hv);
        add_and(vec1);

        vec.pb(num++);
    }

    add_or(vec);
//    cerr << num << el << el;

    two = num++;
    vec.clear();
    vec.pb(two);
    vec.pb(one);

    add_and(vec);
//    cerr << num << el << el;

    int six = num++;

    vec.clear();
    vec.pb(fiv);
    vec.pb(six);

    add_xor(vec);
//    cerr << num << el << el;

    int fst = num++;

    add_not(six);
//    cerr << num << el << el;
//    cerr << num << " " << fst << el;
    vec.clear();

    vec.pb(num++);
    vec.pb(fst);

    add_and(vec);
//    cerr << num << el << el;

    return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 3 ms 640 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 3 ms 640 KB Output is correct
35 Correct 3 ms 640 KB Output is correct
36 Correct 3 ms 640 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 3 ms 640 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 3 ms 640 KB Output is correct
35 Correct 3 ms 640 KB Output is correct
36 Correct 3 ms 640 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 21 ms 2432 KB Output is correct
39 Correct 5 ms 640 KB Output is correct
40 Correct 4 ms 896 KB Output is correct
41 Correct 6 ms 1152 KB Output is correct
42 Correct 4 ms 768 KB Output is correct
43 Correct 8 ms 1280 KB Output is correct
44 Correct 21 ms 2432 KB Output is correct
45 Correct 26 ms 2816 KB Output is correct
46 Correct 20 ms 2304 KB Output is correct
47 Correct 6 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 640 KB Output is correct
2 Correct 20 ms 1792 KB Output is correct
3 Correct 19 ms 1784 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 4 ms 1280 KB Output is correct
6 Correct 18 ms 2304 KB Output is correct
7 Correct 21 ms 2304 KB Output is correct
8 Correct 2 ms 1152 KB Output is correct
9 Correct 4 ms 640 KB Output is correct
10 Correct 16 ms 1536 KB Output is correct
11 Correct 21 ms 1792 KB Output is correct
12 Correct 19 ms 1784 KB Output is correct
13 Correct 16 ms 1536 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 1280 KB Output is correct
16 Correct 20 ms 2176 KB Output is correct
17 Correct 22 ms 2432 KB Output is correct
18 Correct 20 ms 2432 KB Output is correct
19 Correct 15 ms 2048 KB Output is correct
20 Correct 3 ms 1024 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 4 ms 1024 KB Output is correct
4 Correct 10 ms 1408 KB Output is correct
5 Correct 10 ms 1536 KB Output is correct
6 Correct 8 ms 1280 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 6 ms 1024 KB Output is correct
9 Correct 18 ms 1792 KB Output is correct
10 Correct 19 ms 2048 KB Output is correct
11 Correct 15 ms 1664 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 3 ms 640 KB Output is correct
14 Correct 19 ms 1664 KB Output is correct
15 Correct 17 ms 1536 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 4 ms 1280 KB Output is correct
18 Correct 20 ms 2432 KB Output is correct
19 Correct 2 ms 1024 KB Output is correct
20 Incorrect 15 ms 2172 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 3188 KB on inputs (196, 156), (197, 156), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 3 ms 640 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 3 ms 640 KB Output is correct
35 Correct 3 ms 640 KB Output is correct
36 Correct 3 ms 640 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 21 ms 2432 KB Output is correct
39 Correct 5 ms 640 KB Output is correct
40 Correct 4 ms 896 KB Output is correct
41 Correct 6 ms 1152 KB Output is correct
42 Correct 4 ms 768 KB Output is correct
43 Correct 8 ms 1280 KB Output is correct
44 Correct 21 ms 2432 KB Output is correct
45 Correct 26 ms 2816 KB Output is correct
46 Correct 20 ms 2304 KB Output is correct
47 Correct 6 ms 1152 KB Output is correct
48 Correct 3 ms 640 KB Output is correct
49 Correct 20 ms 1792 KB Output is correct
50 Correct 19 ms 1784 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 4 ms 1280 KB Output is correct
53 Correct 18 ms 2304 KB Output is correct
54 Correct 21 ms 2304 KB Output is correct
55 Correct 2 ms 1152 KB Output is correct
56 Correct 4 ms 640 KB Output is correct
57 Correct 16 ms 1536 KB Output is correct
58 Correct 21 ms 1792 KB Output is correct
59 Correct 19 ms 1784 KB Output is correct
60 Correct 16 ms 1536 KB Output is correct
61 Correct 2 ms 384 KB Output is correct
62 Correct 3 ms 1280 KB Output is correct
63 Correct 20 ms 2176 KB Output is correct
64 Correct 22 ms 2432 KB Output is correct
65 Correct 20 ms 2432 KB Output is correct
66 Correct 15 ms 2048 KB Output is correct
67 Correct 3 ms 1024 KB Output is correct
68 Correct 1 ms 384 KB Output is correct
69 Correct 1 ms 384 KB Output is correct
70 Correct 1 ms 384 KB Output is correct
71 Correct 1 ms 384 KB Output is correct
72 Correct 4 ms 1024 KB Output is correct
73 Correct 10 ms 1408 KB Output is correct
74 Correct 10 ms 1536 KB Output is correct
75 Correct 8 ms 1280 KB Output is correct
76 Correct 3 ms 768 KB Output is correct
77 Correct 6 ms 1024 KB Output is correct
78 Correct 18 ms 1792 KB Output is correct
79 Correct 19 ms 2048 KB Output is correct
80 Correct 15 ms 1664 KB Output is correct
81 Correct 5 ms 768 KB Output is correct
82 Correct 3 ms 640 KB Output is correct
83 Correct 19 ms 1664 KB Output is correct
84 Correct 17 ms 1536 KB Output is correct
85 Correct 2 ms 384 KB Output is correct
86 Correct 4 ms 1280 KB Output is correct
87 Correct 20 ms 2432 KB Output is correct
88 Correct 2 ms 1024 KB Output is correct
89 Incorrect 15 ms 2172 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
90 Halted 0 ms 0 KB -