답안 #256578

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256578 2020-08-02T21:23:32 Z fivefourthreeone Vision Program (IOI19_vision) C++17
100 / 100
52 ms 5492 KB
#include <bits/stdc++.h>
#include "vision.h"
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
int h, w, k;
int cnt, nxt;
/*int tt = 0;
int arr[1000001];
void add_not(int a){
    arr[nxt++] = arr[a]^1;
}
void add_or(vector<int> a){
    int nw = 0;
    for(int p: a) {
        nw|=arr[p];
    }
    arr[nxt++] = nw;
}
void add_and(vector<int> a){
    int nw = 1;
    for(int p: a) {
        nw&=arr[p];
    }
    arr[nxt++] = nw;
}
void add_xor(vector<int> a){
    int nw = 0;
    for(int p: a) {
        nw^=arr[p];
    }
    arr[nxt++] = nw;
}*/
int _add_not(int a) {add_not(a);return cnt++;}
int _add_or(vector<int> a) {add_or(a);return cnt++;}
int _add_and(vector<int> a) {add_and(a);return cnt++;}
int _add_xor(vector<int> a) {add_xor(a);return cnt++;}
int val(int x, int y) {
    return x*w + y;
}
int solve(int d) {
    //query for all up diagonals
    vector<int> qq;
    vector<int> up;
    vector<int> down;
    owo(i, 0, h) {
        qq.clear();
        owo(j, 0, min(i+1, w)) {
            qq.senpai(val(i-j, j));
        }
        up.senpai(_add_and({_add_or(qq), _add_xor(qq)}));
    }
    owo(i, 1, w) {
        qq.clear();
        owo(j, 0, min(h, w-i)) {
            qq.senpai(val(h-j-1, i+j));
        }
        up.senpai(_add_and({_add_or(qq), _add_xor(qq)}));
    }
    //query for down diagonals
    uwu(i, h, 0) {
        qq.clear();
        owo(j, 0, min(h-i, w)) {
            qq.senpai(val(i+j, j));
        }
        down.senpai(_add_and({_add_or(qq), _add_xor(qq)}));
    }
    owo(i, 1, w) {
        qq.clear();
        owo(j, 0, min(h, w-i)) {
            qq.senpai(val(j, i+j));
        }
        down.senpai(_add_and({_add_or(qq), _add_xor(qq)}));
    }
    vector<int> preup;
    owo(i, 0, up.size()) {
        if(i==0)preup.senpai(_add_xor({up[i]}));
        else {
            preup.senpai(_add_xor({up[i], preup[i-1]}));
        }
    }
    vector<int> predown;
    owo(i, 0, down.size()) {
        if(i==0)predown.senpai(_add_xor({down[i]}));
        else {
            predown.senpai(_add_xor({down[i], predown[i-1]}));
        }
    }
    int upval = 0;
    int downval = 0;
    owo(i, 0, preup.size()-d) {
        qq.clear();
        owo(j, i, i+d) {
            qq.senpai(preup[j]);
        }
        if(i==0) {
            upval = _add_or({_add_and(qq)});
        }else {
            upval = _add_or({upval, _add_and(qq)});
        }
    }
    owo(i, 0, predown.size()-d) {
        qq.clear();
        owo(j, i, i+d) {
            qq.senpai(predown[j]);
        }
        if(i==0) {
            downval = _add_or({_add_and(qq)});
        }else {
            downval = _add_or({downval, _add_and(qq)});
        }
    }
    return _add_or({upval, downval});
}
void construct_network(int H, int W, int K) {
    h = H;
    w = W;
    k = K;
    cnt = h*w;
    nxt = h*w;
    if(w+h-2==k) {
        solve(k);
    }
    else _add_and({solve(k), _add_not(solve(k+1))});
}
/*int n, m, f;
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>m>>f;
    owo(i, 0, n) {
        owo(j, 0, m) {
            cin>>arr[i*m+j];
        }
    }
    construct_network(n, m, f);
    cout<<(arr[--nxt])<<"\n";
    return 0;
}*/

Compilation message

vision.cpp: In function 'int solve(int)':
vision.cpp:3:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define owo(i,a, b) for(int i=(a);i<(b); ++i)
                                    ^
vision.cpp:96:5: note: in expansion of macro 'owo'
     owo(i, 0, up.size()) {
     ^~~
vision.cpp:3:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define owo(i,a, b) for(int i=(a);i<(b); ++i)
                                    ^
vision.cpp:103:5: note: in expansion of macro 'owo'
     owo(i, 0, down.size()) {
     ^~~
vision.cpp:3:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define owo(i,a, b) for(int i=(a);i<(b); ++i)
                                    ^
vision.cpp:111:5: note: in expansion of macro 'owo'
     owo(i, 0, preup.size()-d) {
     ^~~
vision.cpp:3:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define owo(i,a, b) for(int i=(a);i<(b); ++i)
                                    ^
vision.cpp:122:5: note: in expansion of macro 'owo'
     owo(i, 0, predown.size()-d) {
     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 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 0 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 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 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 2 ms 512 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 2 ms 512 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 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 2 ms 512 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 2 ms 512 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 14 ms 1660 KB Output is correct
39 Correct 3 ms 640 KB Output is correct
40 Correct 2 ms 512 KB Output is correct
41 Correct 8 ms 896 KB Output is correct
42 Correct 6 ms 896 KB Output is correct
43 Correct 11 ms 1404 KB Output is correct
44 Correct 13 ms 1660 KB Output is correct
45 Correct 15 ms 1664 KB Output is correct
46 Correct 14 ms 1536 KB Output is correct
47 Correct 5 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 7 ms 1024 KB Output is correct
3 Correct 6 ms 1024 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 4 ms 640 KB Output is correct
6 Correct 6 ms 892 KB Output is correct
7 Correct 6 ms 896 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 5 ms 892 KB Output is correct
11 Correct 7 ms 1024 KB Output is correct
12 Correct 7 ms 1024 KB Output is correct
13 Correct 7 ms 800 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 5 ms 768 KB Output is correct
16 Correct 6 ms 892 KB Output is correct
17 Correct 11 ms 1024 KB Output is correct
18 Correct 6 ms 1024 KB Output is correct
19 Correct 5 ms 896 KB Output is correct
20 Correct 1 ms 384 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 1 ms 256 KB Output is correct
3 Correct 4 ms 768 KB Output is correct
4 Correct 6 ms 768 KB Output is correct
5 Correct 6 ms 896 KB Output is correct
6 Correct 6 ms 768 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 7 ms 1020 KB Output is correct
9 Correct 10 ms 1280 KB Output is correct
10 Correct 9 ms 1280 KB Output is correct
11 Correct 9 ms 1152 KB Output is correct
12 Correct 4 ms 640 KB Output is correct
13 Correct 3 ms 640 KB Output is correct
14 Correct 6 ms 892 KB Output is correct
15 Correct 6 ms 896 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 3 ms 640 KB Output is correct
18 Correct 11 ms 1024 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 20 ms 2292 KB Output is correct
21 Correct 27 ms 3060 KB Output is correct
22 Correct 29 ms 2940 KB Output is correct
23 Correct 12 ms 1280 KB Output is correct
24 Correct 20 ms 2300 KB Output is correct
25 Correct 26 ms 3060 KB Output is correct
26 Correct 10 ms 1280 KB Output is correct
27 Correct 36 ms 4084 KB Output is correct
28 Correct 47 ms 5232 KB Output is correct
29 Correct 50 ms 5492 KB Output is correct
30 Correct 44 ms 5108 KB Output is correct
31 Correct 18 ms 2040 KB Output is correct
32 Correct 1 ms 256 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 4080 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 4 ms 768 KB Output is correct
4 Correct 8 ms 1020 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 3 ms 768 KB Output is correct
7 Correct 20 ms 2300 KB Output is correct
8 Correct 20 ms 2300 KB Output is correct
9 Correct 35 ms 4120 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 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 2 ms 512 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 2 ms 512 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 14 ms 1660 KB Output is correct
39 Correct 3 ms 640 KB Output is correct
40 Correct 2 ms 512 KB Output is correct
41 Correct 8 ms 896 KB Output is correct
42 Correct 6 ms 896 KB Output is correct
43 Correct 11 ms 1404 KB Output is correct
44 Correct 13 ms 1660 KB Output is correct
45 Correct 15 ms 1664 KB Output is correct
46 Correct 14 ms 1536 KB Output is correct
47 Correct 5 ms 768 KB Output is correct
48 Correct 3 ms 768 KB Output is correct
49 Correct 7 ms 1024 KB Output is correct
50 Correct 6 ms 1024 KB Output is correct
51 Correct 1 ms 384 KB Output is correct
52 Correct 4 ms 640 KB Output is correct
53 Correct 6 ms 892 KB Output is correct
54 Correct 6 ms 896 KB Output is correct
55 Correct 2 ms 640 KB Output is correct
56 Correct 3 ms 768 KB Output is correct
57 Correct 5 ms 892 KB Output is correct
58 Correct 7 ms 1024 KB Output is correct
59 Correct 7 ms 1024 KB Output is correct
60 Correct 7 ms 800 KB Output is correct
61 Correct 1 ms 384 KB Output is correct
62 Correct 5 ms 768 KB Output is correct
63 Correct 6 ms 892 KB Output is correct
64 Correct 11 ms 1024 KB Output is correct
65 Correct 6 ms 1024 KB Output is correct
66 Correct 5 ms 896 KB Output is correct
67 Correct 1 ms 384 KB Output is correct
68 Correct 0 ms 256 KB Output is correct
69 Correct 0 ms 256 KB Output is correct
70 Correct 1 ms 256 KB Output is correct
71 Correct 1 ms 256 KB Output is correct
72 Correct 4 ms 768 KB Output is correct
73 Correct 6 ms 768 KB Output is correct
74 Correct 6 ms 896 KB Output is correct
75 Correct 6 ms 768 KB Output is correct
76 Correct 2 ms 512 KB Output is correct
77 Correct 7 ms 1020 KB Output is correct
78 Correct 10 ms 1280 KB Output is correct
79 Correct 9 ms 1280 KB Output is correct
80 Correct 9 ms 1152 KB Output is correct
81 Correct 4 ms 640 KB Output is correct
82 Correct 3 ms 640 KB Output is correct
83 Correct 6 ms 892 KB Output is correct
84 Correct 6 ms 896 KB Output is correct
85 Correct 1 ms 384 KB Output is correct
86 Correct 3 ms 640 KB Output is correct
87 Correct 11 ms 1024 KB Output is correct
88 Correct 2 ms 384 KB Output is correct
89 Correct 20 ms 2292 KB Output is correct
90 Correct 27 ms 3060 KB Output is correct
91 Correct 29 ms 2940 KB Output is correct
92 Correct 12 ms 1280 KB Output is correct
93 Correct 20 ms 2300 KB Output is correct
94 Correct 26 ms 3060 KB Output is correct
95 Correct 10 ms 1280 KB Output is correct
96 Correct 36 ms 4084 KB Output is correct
97 Correct 47 ms 5232 KB Output is correct
98 Correct 50 ms 5492 KB Output is correct
99 Correct 44 ms 5108 KB Output is correct
100 Correct 18 ms 2040 KB Output is correct
101 Correct 1 ms 256 KB Output is correct
102 Correct 1 ms 256 KB Output is correct
103 Correct 40 ms 4080 KB Output is correct
104 Correct 1 ms 256 KB Output is correct
105 Correct 4 ms 768 KB Output is correct
106 Correct 8 ms 1020 KB Output is correct
107 Correct 3 ms 768 KB Output is correct
108 Correct 3 ms 768 KB Output is correct
109 Correct 20 ms 2300 KB Output is correct
110 Correct 20 ms 2300 KB Output is correct
111 Correct 35 ms 4120 KB Output is correct
112 Correct 1 ms 256 KB Output is correct
113 Correct 0 ms 256 KB Output is correct
114 Correct 49 ms 5232 KB Output is correct
115 Correct 3 ms 640 KB Output is correct
116 Correct 3 ms 768 KB Output is correct
117 Correct 22 ms 2684 KB Output is correct
118 Correct 25 ms 2804 KB Output is correct
119 Correct 51 ms 5488 KB Output is correct
120 Correct 51 ms 5488 KB Output is correct
121 Correct 52 ms 5492 KB Output is correct
122 Correct 51 ms 5492 KB Output is correct
123 Correct 38 ms 4080 KB Output is correct
124 Correct 47 ms 5232 KB Output is correct
125 Correct 51 ms 5492 KB Output is correct
126 Correct 51 ms 5492 KB Output is correct
127 Correct 46 ms 5108 KB Output is correct
128 Correct 18 ms 2168 KB Output is correct