Submission #600421

# Submission time Handle Problem Language Result Execution time Memory
600421 2022-07-20T20:38:00 Z MohamedFaresNebili Vision Program (IOI19_vision) C++14
100 / 100
127 ms 7936 KB
#include <bits/stdc++.h>
#include "vision.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")

                using namespace std;

                using ll = long long;
                using ld = long double;
                using ii = pair<ll, ll>;
                using vi = vector<int>;

                #define ff first
                #define ss second
                #define pb push_back
                #define all(x) (x).begin(), (x).end()
                #define lb lower_bound

                const int MOD = 1e9 + 7;

                int H, W;
                map<int, int> A[2], B[2];

                int dist(int x, int y, int X, int Y) {
                    return abs(x - X) + abs(y - Y);
                }
                int calc(int x, int y) {
                    return x * W + y;
                }
                int diagR(int K) {
                    vector<int> V;
                    for(int l = 0; l < H + W; l++) {
                        if(l + K - 1 < H + W - 1) {
                            vector<int> X, Y;
                            for(int i = l; i < l + K; i++)
                                X.push_back(A[0][i]), Y.push_back(B[0][i]);
                            int C = add_xor({add_or(X), add_xor(X)});
                            Y.push_back(C); V.push_back(add_or(Y));
                        }
                    }
                    return add_or(V);
                }
                int diagL(int K) {
                    vector<int> V;
                    for(int l = -W + 1; l < H; l++) {
                        if(l + K - 1 < H) {
                            vector<int> X, Y;
                            for(int i = l; i < l + K; i++)
                                X.push_back(A[1][i]), Y.push_back(B[1][i]);
                            int C = add_xor({add_or(X), add_xor(X)});
                            Y.push_back(C); V.push_back(add_or(Y));
                        }
                    }
                    return add_or(V);
                }
                int solve(int K) {
                    return add_and({diagR(K), diagL(K)});
                }

                void construct_network(int h, int w, int K) {
                    H = h, W = w;
                    for(int l = 0; l < H + W; l++) {
                        vector<int> V;
                        for(int i = 0; i < H; i++)
                            for(int j = 0; j < W; j++)
                                if(i + j == l) V.push_back(calc(i, j));
                        if(V.empty()) continue;
                        A[0][l] = add_or(V);
                        B[0][l] = add_xor({add_or(V), add_xor(V)});
                    }
                    for(int l = -H - W; l < H + W; l++) {
                        vector<int> V;
                        for(int i = 0; i < H; i++)
                            for(int j = 0; j < W; j++)
                                if(i - j == l) V.push_back(calc(i, j));
                        if(V.empty()) continue;
                        A[1][l] = add_or(V);
                        B[1][l] = add_xor({add_or(V), add_xor(V)});
                    }
                    add_and({solve(K + 1), add_not(solve(K))});
                }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 296 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 296 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 468 KB Output is correct
35 Correct 3 ms 428 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 296 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 468 KB Output is correct
35 Correct 3 ms 428 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 22 ms 2000 KB Output is correct
39 Correct 3 ms 596 KB Output is correct
40 Correct 4 ms 468 KB Output is correct
41 Correct 7 ms 852 KB Output is correct
42 Correct 6 ms 688 KB Output is correct
43 Correct 11 ms 1232 KB Output is correct
44 Correct 21 ms 2028 KB Output is correct
45 Correct 25 ms 2156 KB Output is correct
46 Correct 19 ms 1852 KB Output is correct
47 Correct 10 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 16 ms 1620 KB Output is correct
3 Correct 13 ms 1492 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 724 KB Output is correct
6 Correct 12 ms 1384 KB Output is correct
7 Correct 12 ms 1364 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 3 ms 680 KB Output is correct
10 Correct 13 ms 1324 KB Output is correct
11 Correct 19 ms 1488 KB Output is correct
12 Correct 13 ms 1580 KB Output is correct
13 Correct 11 ms 1236 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 3 ms 724 KB Output is correct
16 Correct 12 ms 1304 KB Output is correct
17 Correct 13 ms 1512 KB Output is correct
18 Correct 14 ms 1492 KB Output is correct
19 Correct 10 ms 1244 KB Output is correct
20 Correct 2 ms 424 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 8 ms 976 KB Output is correct
5 Correct 9 ms 1020 KB Output is correct
6 Correct 7 ms 852 KB Output is correct
7 Correct 4 ms 556 KB Output is correct
8 Correct 7 ms 852 KB Output is correct
9 Correct 13 ms 1452 KB Output is correct
10 Correct 18 ms 1580 KB Output is correct
11 Correct 13 ms 1364 KB Output is correct
12 Correct 7 ms 724 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 12 ms 1416 KB Output is correct
15 Correct 13 ms 1364 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 3 ms 724 KB Output is correct
18 Correct 15 ms 1552 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 29 ms 1916 KB Output is correct
21 Correct 51 ms 4136 KB Output is correct
22 Correct 51 ms 4108 KB Output is correct
23 Correct 23 ms 1568 KB Output is correct
24 Correct 23 ms 2032 KB Output is correct
25 Correct 54 ms 4380 KB Output is correct
26 Correct 23 ms 1620 KB Output is correct
27 Correct 56 ms 3352 KB Output is correct
28 Correct 95 ms 6728 KB Output is correct
29 Correct 98 ms 7820 KB Output is correct
30 Correct 89 ms 6592 KB Output is correct
31 Correct 51 ms 2892 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 3380 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 7 ms 852 KB Output is correct
5 Correct 3 ms 724 KB Output is correct
6 Correct 3 ms 724 KB Output is correct
7 Correct 26 ms 1920 KB Output is correct
8 Correct 25 ms 2028 KB Output is correct
9 Correct 66 ms 3320 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 296 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 468 KB Output is correct
35 Correct 3 ms 428 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 22 ms 2000 KB Output is correct
39 Correct 3 ms 596 KB Output is correct
40 Correct 4 ms 468 KB Output is correct
41 Correct 7 ms 852 KB Output is correct
42 Correct 6 ms 688 KB Output is correct
43 Correct 11 ms 1232 KB Output is correct
44 Correct 21 ms 2028 KB Output is correct
45 Correct 25 ms 2156 KB Output is correct
46 Correct 19 ms 1852 KB Output is correct
47 Correct 10 ms 980 KB Output is correct
48 Correct 3 ms 724 KB Output is correct
49 Correct 16 ms 1620 KB Output is correct
50 Correct 13 ms 1492 KB Output is correct
51 Correct 2 ms 468 KB Output is correct
52 Correct 3 ms 724 KB Output is correct
53 Correct 12 ms 1384 KB Output is correct
54 Correct 12 ms 1364 KB Output is correct
55 Correct 2 ms 468 KB Output is correct
56 Correct 3 ms 680 KB Output is correct
57 Correct 13 ms 1324 KB Output is correct
58 Correct 19 ms 1488 KB Output is correct
59 Correct 13 ms 1580 KB Output is correct
60 Correct 11 ms 1236 KB Output is correct
61 Correct 2 ms 468 KB Output is correct
62 Correct 3 ms 724 KB Output is correct
63 Correct 12 ms 1304 KB Output is correct
64 Correct 13 ms 1512 KB Output is correct
65 Correct 14 ms 1492 KB Output is correct
66 Correct 10 ms 1244 KB Output is correct
67 Correct 2 ms 424 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 1 ms 304 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 4 ms 724 KB Output is correct
73 Correct 8 ms 976 KB Output is correct
74 Correct 9 ms 1020 KB Output is correct
75 Correct 7 ms 852 KB Output is correct
76 Correct 4 ms 556 KB Output is correct
77 Correct 7 ms 852 KB Output is correct
78 Correct 13 ms 1452 KB Output is correct
79 Correct 18 ms 1580 KB Output is correct
80 Correct 13 ms 1364 KB Output is correct
81 Correct 7 ms 724 KB Output is correct
82 Correct 3 ms 724 KB Output is correct
83 Correct 12 ms 1416 KB Output is correct
84 Correct 13 ms 1364 KB Output is correct
85 Correct 2 ms 468 KB Output is correct
86 Correct 3 ms 724 KB Output is correct
87 Correct 15 ms 1552 KB Output is correct
88 Correct 2 ms 468 KB Output is correct
89 Correct 29 ms 1916 KB Output is correct
90 Correct 51 ms 4136 KB Output is correct
91 Correct 51 ms 4108 KB Output is correct
92 Correct 23 ms 1568 KB Output is correct
93 Correct 23 ms 2032 KB Output is correct
94 Correct 54 ms 4380 KB Output is correct
95 Correct 23 ms 1620 KB Output is correct
96 Correct 56 ms 3352 KB Output is correct
97 Correct 95 ms 6728 KB Output is correct
98 Correct 98 ms 7820 KB Output is correct
99 Correct 89 ms 6592 KB Output is correct
100 Correct 51 ms 2892 KB Output is correct
101 Correct 0 ms 212 KB Output is correct
102 Correct 0 ms 212 KB Output is correct
103 Correct 56 ms 3380 KB Output is correct
104 Correct 1 ms 212 KB Output is correct
105 Correct 4 ms 724 KB Output is correct
106 Correct 7 ms 852 KB Output is correct
107 Correct 3 ms 724 KB Output is correct
108 Correct 3 ms 724 KB Output is correct
109 Correct 26 ms 1920 KB Output is correct
110 Correct 25 ms 2028 KB Output is correct
111 Correct 66 ms 3320 KB Output is correct
112 Correct 0 ms 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 90 ms 6728 KB Output is correct
115 Correct 2 ms 468 KB Output is correct
116 Correct 3 ms 684 KB Output is correct
117 Correct 38 ms 3132 KB Output is correct
118 Correct 38 ms 3332 KB Output is correct
119 Correct 104 ms 7792 KB Output is correct
120 Correct 101 ms 7784 KB Output is correct
121 Correct 99 ms 7884 KB Output is correct
122 Correct 127 ms 7832 KB Output is correct
123 Correct 52 ms 3396 KB Output is correct
124 Correct 92 ms 6772 KB Output is correct
125 Correct 113 ms 7804 KB Output is correct
126 Correct 105 ms 7936 KB Output is correct
127 Correct 89 ms 6628 KB Output is correct
128 Correct 49 ms 2912 KB Output is correct