답안 #425241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
425241 2021-06-12T17:19:12 Z oleh1421 Vision Program (IOI19_vision) C++17
100 / 100
67 ms 5060 KB
//#include "grader.cpp"

#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int,vector<int>>vr,vc;
void construct_network(int H, int W, int K) {

    int ind=H*W-1;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            vr[i-j].push_back(i*W+j);
            vc[i+j].push_back(i*W+j);
        }
    }
    vector<pair<int,int> >r;
    for (auto cur:vr){
        add_xor(cur.second);
        r.push_back({cur.first,++ind});
    }
    vector<pair<int,int> >c;
    for (auto cur:vc){
        add_xor(cur.second);
        c.push_back({cur.first,++ind});
    }
    vector<int>Lr,Er;
    for (int i=0;i<r.size();i++){
        vector<int>v;
        for (int j=i;j<r.size() && r[j].first-r[i].first<K;j++){
            v.push_back(r[j].second);
        }
        add_or(v);
        int Or=++ind;
        add_xor(v);
        int Xr=++ind;
        add_not(Xr);
        Xr=++ind;
        add_and({Or,Xr});
        Lr.push_back(++ind);
        int pos=-1;
        for (int j=i;j<r.size();j++){
            if (r[j].first-r[i].first==K){
                pos=j;
                break;
            }
        }
        if (pos!=-1) {
            add_and({r[i].second,r[pos].second});
            Er.push_back(++ind);
//            cout<<i<<" "<<r[i].first<<" "<<ind<<" "<<r[i].second<<" "<<r[pos].second<<endl;
        }
    }
    vector<int>askr;
    for (auto cur:r) askr.push_back(cur.second);
    add_or(askr);
    ++ind;
    add_not(ind);
    ++ind;
    Lr.push_back(ind);

    vector<int>Lc,Ec;
    for (int i=0;i<c.size();i++){
        vector<int>v;
        for (int j=i;j<c.size() && c[j].first-c[i].first<K;j++){
            v.push_back(c[j].second);
//            cout<<c[j].first<<" ";
        }
//        cout<<endl;

        add_or(v);
        int Or=++ind;
        add_xor(v);
        int Xr=++ind;
        add_not(Xr);
        Xr=++ind;
        add_and({Or,Xr});
        Lc.push_back(++ind);
        int pos=-1;
        for (int j=i;j<c.size();j++){
            if (c[j].first-c[i].first==K){
                pos=j;
                break;
            }
        }
        if (pos!=-1) {
            add_and({c[i].second,c[pos].second});
            Ec.push_back(++ind);
//            cout<<i<<" "<<c[i].first<<" "<<ind<<" "<<c[i].second<<" "<<c[pos].second<<endl;
        }
    }
    vector<int>askc;
    for (auto cur:c) askc.push_back(cur.second);
    add_or(askc);
    ++ind;
    add_not(ind);
    ++ind;
    Lc.push_back(ind);
    add_or(Lr);
    int OrA=++ind;
    add_or(Er);
    int OrB=++ind;
    add_or(Lc);
    int OrC=++ind;
    add_or(Ec);
    int OrD=++ind;
    add_and({OrA,OrD});
    int A=++ind;
    add_and({OrB,OrC});
    int B=++ind;
    add_and({OrB,OrD});
    int C=++ind;

    add_or({A,B,C});
    ind++;
//    cout<<OrA<<" "<<OrB<<" "<<OrC<<" "<<OrD<<" "<<A<<" "<<B<<" "<<C<<endl;




}
/**
2 3 3
0 0 0 1
0 0 0 2
0 0 1 0
0 0 1 1
0 0 1 2
0 1 0 2
0 1 1 0
0 1 1 1
0 1 1 2
0 2 1 0
0 2 1 1
0 2 1 2
1 0 1 1
1 0 1 2
1 1 1 2
-1

**/

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:28:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i=0;i<r.size();i++){
      |                  ~^~~~~~~~~
vision.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for (int j=i;j<r.size() && r[j].first-r[i].first<K;j++){
      |                      ~^~~~~~~~~
vision.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int j=i;j<r.size();j++){
      |                      ~^~~~~~~~~
vision.cpp:63:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for (int i=0;i<c.size();i++){
      |                  ~^~~~~~~~~
vision.cpp:65:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for (int j=i;j<c.size() && c[j].first-c[i].first<K;j++){
      |                      ~^~~~~~~~~
vision.cpp:80:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |         for (int j=i;j<c.size();j++){
      |                      ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 288 KB Output is correct
26 Correct 1 ms 288 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 288 KB Output is correct
26 Correct 1 ms 288 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 2 ms 420 KB Output is correct
37 Correct 2 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 288 KB Output is correct
26 Correct 1 ms 288 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 2 ms 420 KB Output is correct
37 Correct 2 ms 420 KB Output is correct
38 Correct 9 ms 1184 KB Output is correct
39 Correct 2 ms 460 KB Output is correct
40 Correct 3 ms 460 KB Output is correct
41 Correct 5 ms 588 KB Output is correct
42 Correct 8 ms 972 KB Output is correct
43 Correct 5 ms 864 KB Output is correct
44 Correct 9 ms 1184 KB Output is correct
45 Correct 12 ms 1356 KB Output is correct
46 Correct 13 ms 1572 KB Output is correct
47 Correct 14 ms 1456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 588 KB Output is correct
2 Correct 8 ms 972 KB Output is correct
3 Correct 11 ms 1000 KB Output is correct
4 Correct 10 ms 1056 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 7 ms 844 KB Output is correct
7 Correct 9 ms 1100 KB Output is correct
8 Correct 10 ms 1028 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 6 ms 844 KB Output is correct
11 Correct 11 ms 972 KB Output is correct
12 Correct 9 ms 1008 KB Output is correct
13 Correct 10 ms 1068 KB Output is correct
14 Correct 10 ms 1044 KB Output is correct
15 Correct 2 ms 568 KB Output is correct
16 Correct 6 ms 844 KB Output is correct
17 Correct 8 ms 936 KB Output is correct
18 Correct 11 ms 972 KB Output is correct
19 Correct 10 ms 1052 KB Output is correct
20 Correct 10 ms 1100 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 420 KB Output is correct
4 Correct 4 ms 544 KB Output is correct
5 Correct 5 ms 712 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
7 Correct 6 ms 716 KB Output is correct
8 Correct 5 ms 844 KB Output is correct
9 Correct 6 ms 972 KB Output is correct
10 Correct 9 ms 1100 KB Output is correct
11 Correct 12 ms 1100 KB Output is correct
12 Correct 12 ms 1080 KB Output is correct
13 Correct 3 ms 544 KB Output is correct
14 Correct 6 ms 844 KB Output is correct
15 Correct 9 ms 1056 KB Output is correct
16 Correct 10 ms 1048 KB Output is correct
17 Correct 2 ms 548 KB Output is correct
18 Correct 9 ms 972 KB Output is correct
19 Correct 11 ms 1092 KB Output is correct
20 Correct 9 ms 1200 KB Output is correct
21 Correct 20 ms 2136 KB Output is correct
22 Correct 27 ms 2764 KB Output is correct
23 Correct 29 ms 2884 KB Output is correct
24 Correct 9 ms 1204 KB Output is correct
25 Correct 24 ms 2508 KB Output is correct
26 Correct 29 ms 2872 KB Output is correct
27 Correct 17 ms 2124 KB Output is correct
28 Correct 31 ms 3228 KB Output is correct
29 Correct 42 ms 4284 KB Output is correct
30 Correct 63 ms 4852 KB Output is correct
31 Correct 53 ms 5060 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 2060 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 4 ms 716 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 11 ms 1228 KB Output is correct
8 Correct 11 ms 1228 KB Output is correct
9 Correct 16 ms 2024 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 288 KB Output is correct
26 Correct 1 ms 288 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 2 ms 420 KB Output is correct
37 Correct 2 ms 420 KB Output is correct
38 Correct 9 ms 1184 KB Output is correct
39 Correct 2 ms 460 KB Output is correct
40 Correct 3 ms 460 KB Output is correct
41 Correct 5 ms 588 KB Output is correct
42 Correct 8 ms 972 KB Output is correct
43 Correct 5 ms 864 KB Output is correct
44 Correct 9 ms 1184 KB Output is correct
45 Correct 12 ms 1356 KB Output is correct
46 Correct 13 ms 1572 KB Output is correct
47 Correct 14 ms 1456 KB Output is correct
48 Correct 3 ms 588 KB Output is correct
49 Correct 8 ms 972 KB Output is correct
50 Correct 11 ms 1000 KB Output is correct
51 Correct 10 ms 1056 KB Output is correct
52 Correct 2 ms 588 KB Output is correct
53 Correct 7 ms 844 KB Output is correct
54 Correct 9 ms 1100 KB Output is correct
55 Correct 10 ms 1028 KB Output is correct
56 Correct 2 ms 588 KB Output is correct
57 Correct 6 ms 844 KB Output is correct
58 Correct 11 ms 972 KB Output is correct
59 Correct 9 ms 1008 KB Output is correct
60 Correct 10 ms 1068 KB Output is correct
61 Correct 10 ms 1044 KB Output is correct
62 Correct 2 ms 568 KB Output is correct
63 Correct 6 ms 844 KB Output is correct
64 Correct 8 ms 936 KB Output is correct
65 Correct 11 ms 972 KB Output is correct
66 Correct 10 ms 1052 KB Output is correct
67 Correct 10 ms 1100 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 288 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 2 ms 420 KB Output is correct
73 Correct 4 ms 544 KB Output is correct
74 Correct 5 ms 712 KB Output is correct
75 Correct 6 ms 716 KB Output is correct
76 Correct 6 ms 716 KB Output is correct
77 Correct 5 ms 844 KB Output is correct
78 Correct 6 ms 972 KB Output is correct
79 Correct 9 ms 1100 KB Output is correct
80 Correct 12 ms 1100 KB Output is correct
81 Correct 12 ms 1080 KB Output is correct
82 Correct 3 ms 544 KB Output is correct
83 Correct 6 ms 844 KB Output is correct
84 Correct 9 ms 1056 KB Output is correct
85 Correct 10 ms 1048 KB Output is correct
86 Correct 2 ms 548 KB Output is correct
87 Correct 9 ms 972 KB Output is correct
88 Correct 11 ms 1092 KB Output is correct
89 Correct 9 ms 1200 KB Output is correct
90 Correct 20 ms 2136 KB Output is correct
91 Correct 27 ms 2764 KB Output is correct
92 Correct 29 ms 2884 KB Output is correct
93 Correct 9 ms 1204 KB Output is correct
94 Correct 24 ms 2508 KB Output is correct
95 Correct 29 ms 2872 KB Output is correct
96 Correct 17 ms 2124 KB Output is correct
97 Correct 31 ms 3228 KB Output is correct
98 Correct 42 ms 4284 KB Output is correct
99 Correct 63 ms 4852 KB Output is correct
100 Correct 53 ms 5060 KB Output is correct
101 Correct 1 ms 204 KB Output is correct
102 Correct 1 ms 204 KB Output is correct
103 Correct 16 ms 2060 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 2 ms 460 KB Output is correct
106 Correct 4 ms 716 KB Output is correct
107 Correct 2 ms 588 KB Output is correct
108 Correct 2 ms 588 KB Output is correct
109 Correct 11 ms 1228 KB Output is correct
110 Correct 11 ms 1228 KB Output is correct
111 Correct 16 ms 2024 KB Output is correct
112 Correct 1 ms 204 KB Output is correct
113 Correct 1 ms 292 KB Output is correct
114 Correct 31 ms 3340 KB Output is correct
115 Correct 10 ms 1100 KB Output is correct
116 Correct 2 ms 588 KB Output is correct
117 Correct 29 ms 2896 KB Output is correct
118 Correct 19 ms 1752 KB Output is correct
119 Correct 42 ms 4152 KB Output is correct
120 Correct 42 ms 4288 KB Output is correct
121 Correct 42 ms 4260 KB Output is correct
122 Correct 42 ms 4252 KB Output is correct
123 Correct 16 ms 2096 KB Output is correct
124 Correct 31 ms 3300 KB Output is correct
125 Correct 53 ms 4236 KB Output is correct
126 Correct 52 ms 4288 KB Output is correct
127 Correct 48 ms 4784 KB Output is correct
128 Correct 67 ms 5012 KB Output is correct