Submission #1117192

# Submission time Handle Problem Language Result Execution time Memory
1117192 2024-11-22T22:16:20 Z epicci23 Vision Program (IOI19_vision) C++17
100 / 100
43 ms 5580 KB
#include "bits/stdc++.h"
#include "vision.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;

int n,m;

inline int get_ind(int a,int b){
  return a*m+b;
}

inline bool is_valid(int a,int b){
  return a>=0 && a<n && b>=0 && b<m;
}

map<int,int> info1_l,info1_r,info2_l,info2_r;

void construct_network(int _n, int _m, int k){
  n = _n , m = _m;
  
  int p = 0;
  while(p<n){
    int c = p , d = 0;
    vector<int> res;
    while(is_valid(c,d)){
      res.push_back(get_ind(c,d));
      c--,d++;
    }
    info1_l[p] = add_or(res);
    p++;
  }

  p = 1;
  while(p<m){
    int c = n - 1 , d = p;
    vector<int> res;
    while(is_valid(c,d)){
      res.push_back(get_ind(c,d));
      c--,d++;
    }
    info1_l[n-1+p] = add_or(res);
    p++;
  }

  p = 0;
  while(p<n){
    int c = p , d = 0;
    vector<int> res;
    while(is_valid(c,d)){
      res.push_back(get_ind(c,d));
      c--,d++;
    }
    info2_l[p] = add_and({info1_l[p],add_not(add_xor(res))});
    p++;
  }


  p = 1;
  while(p<m){
    int c = n - 1 , d = p;
    vector<int> res;
    while(is_valid(c,d)){
      res.push_back(get_ind(c,d));
      c--,d++;
    }
    info2_l[n-1+p] = add_and({info1_l[n-1+p],add_not(add_xor(res))});
    p++;
  }




  p = n - 1;
  while(p >= 0){
    int c = p , d = 0;
    vector<int> res;
    while(is_valid(c,d)){
      res.push_back(get_ind(c,d));
      c++,d++;
    }
    info1_r[p] = add_or(res);
    p--;
  }

  p = 1;
  while(p<m){
    int c = 0 , d = p;
    vector<int> res;
    while(is_valid(c,d)){
      res.push_back(get_ind(c,d));
      c++,d++;
    }
    info1_r[-p] = add_or(res);
    p++;
  }

  
  p = n - 1;
  while(p >= 0){
    int c = p , d = 0;
    vector<int> res;
    while(is_valid(c,d)){
      res.push_back(get_ind(c,d));
      c++,d++;
    }
    info2_r[p] = add_and({info1_r[p],add_not(add_xor(res))});
    p--;
  }

  p = 1;
  while(p < m){
    int c = 0 , d = p;
    vector<int> res;
    while(is_valid(c,d)){
      res.push_back(get_ind(c,d));
      c++,d++;
    }
    info2_r[-p] = add_and({info1_r[-p],add_not(add_xor(res))});
    p++;
  }

  vector<int> l_diagonals,r_diagonals;
  
  for(int i = 0; i <= n + m - 2; i++) l_diagonals.push_back(i);
  for(int i = n - 1; i >= 1 - m; i--) r_diagonals.push_back(i);
  
  vector<int> ok_l;
  for(int x : l_diagonals) ok_l.push_back(info2_l[x]);
  for(int i = k - 1; i < sz(l_diagonals) ; i++){
     vector<int> res;
     for(int j = i ; j > i - k; j--) res.push_back(info1_l[l_diagonals[j]]);
     ok_l.push_back(add_and({add_or(res),add_not(add_xor(res))}));
  }

  vector<int> ok_r;
  for(int x : r_diagonals) ok_r.push_back(info2_r[x]);
  for(int i = k - 1; i < sz(r_diagonals) ; i++){
     vector<int> res;
     for(int j = i ; j > i - k; j--) res.push_back(info1_r[r_diagonals[j]]);
     ok_r.push_back(add_and({add_or(res),add_not(add_xor(res))}));
  }


  int hm1 = add_and({add_or(ok_l),add_or(ok_r)});
  
  
  ok_l.clear();
  for(int x : l_diagonals) ok_l.push_back(info2_l[x]);
  for(int i = k; i < sz(l_diagonals) ; i++){
     vector<int> res;
     for(int j = i ; j >= i - k; j--) res.push_back(info1_l[l_diagonals[j]]);
     ok_l.push_back(add_and({add_or(res),add_not(add_xor(res))}));
  }

  ok_r.clear();
  for(int x : r_diagonals) ok_r.push_back(info2_r[x]);
  for(int i = k; i < sz(r_diagonals) ; i++){
     vector<int> res;
     for(int j = i ; j >= i - k; j--) res.push_back(info1_r[r_diagonals[j]]);
     ok_r.push_back(add_and({add_or(res),add_not(add_xor(res))}));
  }

  int hm2 = add_and({add_or(ok_l),add_or(ok_r)});

  add_and({add_not({hm1}),hm2});
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 508 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 504 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 508 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 504 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 508 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 504 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 2 ms 592 KB Output is correct
34 Correct 2 ms 444 KB Output is correct
35 Correct 2 ms 592 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 508 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 504 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 2 ms 592 KB Output is correct
34 Correct 2 ms 444 KB Output is correct
35 Correct 2 ms 592 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
38 Correct 8 ms 1616 KB Output is correct
39 Correct 3 ms 592 KB Output is correct
40 Correct 2 ms 592 KB Output is correct
41 Correct 3 ms 692 KB Output is correct
42 Correct 3 ms 660 KB Output is correct
43 Correct 5 ms 964 KB Output is correct
44 Correct 12 ms 1616 KB Output is correct
45 Correct 10 ms 1616 KB Output is correct
46 Correct 8 ms 1360 KB Output is correct
47 Correct 5 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 848 KB Output is correct
2 Correct 8 ms 1360 KB Output is correct
3 Correct 7 ms 1360 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 6 ms 1104 KB Output is correct
7 Correct 6 ms 1104 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 848 KB Output is correct
10 Correct 6 ms 1168 KB Output is correct
11 Correct 7 ms 1360 KB Output is correct
12 Correct 7 ms 1360 KB Output is correct
13 Correct 6 ms 1104 KB Output is correct
14 Correct 2 ms 592 KB Output is correct
15 Correct 3 ms 848 KB Output is correct
16 Correct 6 ms 1064 KB Output is correct
17 Correct 9 ms 1360 KB Output is correct
18 Correct 7 ms 1360 KB Output is correct
19 Correct 5 ms 1104 KB Output is correct
20 Correct 2 ms 592 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 3 ms 592 KB Output is correct
4 Correct 5 ms 848 KB Output is correct
5 Correct 5 ms 860 KB Output is correct
6 Correct 4 ms 740 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 4 ms 972 KB Output is correct
9 Correct 6 ms 1104 KB Output is correct
10 Correct 7 ms 1360 KB Output is correct
11 Correct 6 ms 1104 KB Output is correct
12 Correct 3 ms 592 KB Output is correct
13 Correct 2 ms 848 KB Output is correct
14 Correct 6 ms 1100 KB Output is correct
15 Correct 6 ms 1104 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 3 ms 1016 KB Output is correct
18 Correct 8 ms 1360 KB Output is correct
19 Correct 2 ms 592 KB Output is correct
20 Correct 8 ms 1740 KB Output is correct
21 Correct 19 ms 3020 KB Output is correct
22 Correct 18 ms 2896 KB Output is correct
23 Correct 8 ms 1360 KB Output is correct
24 Correct 9 ms 1740 KB Output is correct
25 Correct 22 ms 3212 KB Output is correct
26 Correct 12 ms 1612 KB Output is correct
27 Correct 14 ms 2932 KB Output is correct
28 Correct 31 ms 4812 KB Output is correct
29 Correct 32 ms 5580 KB Output is correct
30 Correct 28 ms 4980 KB Output is correct
31 Correct 12 ms 2128 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2760 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 3 ms 592 KB Output is correct
4 Correct 4 ms 1140 KB Output is correct
5 Correct 3 ms 848 KB Output is correct
6 Correct 3 ms 1016 KB Output is correct
7 Correct 8 ms 1740 KB Output is correct
8 Correct 8 ms 1740 KB Output is correct
9 Correct 13 ms 2760 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 508 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 504 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 2 ms 592 KB Output is correct
34 Correct 2 ms 444 KB Output is correct
35 Correct 2 ms 592 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
38 Correct 8 ms 1616 KB Output is correct
39 Correct 3 ms 592 KB Output is correct
40 Correct 2 ms 592 KB Output is correct
41 Correct 3 ms 692 KB Output is correct
42 Correct 3 ms 660 KB Output is correct
43 Correct 5 ms 964 KB Output is correct
44 Correct 12 ms 1616 KB Output is correct
45 Correct 10 ms 1616 KB Output is correct
46 Correct 8 ms 1360 KB Output is correct
47 Correct 5 ms 1016 KB Output is correct
48 Correct 4 ms 848 KB Output is correct
49 Correct 8 ms 1360 KB Output is correct
50 Correct 7 ms 1360 KB Output is correct
51 Correct 2 ms 592 KB Output is correct
52 Correct 3 ms 860 KB Output is correct
53 Correct 6 ms 1104 KB Output is correct
54 Correct 6 ms 1104 KB Output is correct
55 Correct 2 ms 592 KB Output is correct
56 Correct 2 ms 848 KB Output is correct
57 Correct 6 ms 1168 KB Output is correct
58 Correct 7 ms 1360 KB Output is correct
59 Correct 7 ms 1360 KB Output is correct
60 Correct 6 ms 1104 KB Output is correct
61 Correct 2 ms 592 KB Output is correct
62 Correct 3 ms 848 KB Output is correct
63 Correct 6 ms 1064 KB Output is correct
64 Correct 9 ms 1360 KB Output is correct
65 Correct 7 ms 1360 KB Output is correct
66 Correct 5 ms 1104 KB Output is correct
67 Correct 2 ms 592 KB Output is correct
68 Correct 1 ms 336 KB Output is correct
69 Correct 1 ms 336 KB Output is correct
70 Correct 1 ms 336 KB Output is correct
71 Correct 1 ms 336 KB Output is correct
72 Correct 3 ms 592 KB Output is correct
73 Correct 5 ms 848 KB Output is correct
74 Correct 5 ms 860 KB Output is correct
75 Correct 4 ms 740 KB Output is correct
76 Correct 2 ms 592 KB Output is correct
77 Correct 4 ms 972 KB Output is correct
78 Correct 6 ms 1104 KB Output is correct
79 Correct 7 ms 1360 KB Output is correct
80 Correct 6 ms 1104 KB Output is correct
81 Correct 3 ms 592 KB Output is correct
82 Correct 2 ms 848 KB Output is correct
83 Correct 6 ms 1100 KB Output is correct
84 Correct 6 ms 1104 KB Output is correct
85 Correct 2 ms 592 KB Output is correct
86 Correct 3 ms 1016 KB Output is correct
87 Correct 8 ms 1360 KB Output is correct
88 Correct 2 ms 592 KB Output is correct
89 Correct 8 ms 1740 KB Output is correct
90 Correct 19 ms 3020 KB Output is correct
91 Correct 18 ms 2896 KB Output is correct
92 Correct 8 ms 1360 KB Output is correct
93 Correct 9 ms 1740 KB Output is correct
94 Correct 22 ms 3212 KB Output is correct
95 Correct 12 ms 1612 KB Output is correct
96 Correct 14 ms 2932 KB Output is correct
97 Correct 31 ms 4812 KB Output is correct
98 Correct 32 ms 5580 KB Output is correct
99 Correct 28 ms 4980 KB Output is correct
100 Correct 12 ms 2128 KB Output is correct
101 Correct 1 ms 504 KB Output is correct
102 Correct 1 ms 336 KB Output is correct
103 Correct 13 ms 2760 KB Output is correct
104 Correct 1 ms 336 KB Output is correct
105 Correct 3 ms 592 KB Output is correct
106 Correct 4 ms 1140 KB Output is correct
107 Correct 3 ms 848 KB Output is correct
108 Correct 3 ms 1016 KB Output is correct
109 Correct 8 ms 1740 KB Output is correct
110 Correct 8 ms 1740 KB Output is correct
111 Correct 13 ms 2760 KB Output is correct
112 Correct 1 ms 336 KB Output is correct
113 Correct 1 ms 336 KB Output is correct
114 Correct 27 ms 4812 KB Output is correct
115 Correct 2 ms 760 KB Output is correct
116 Correct 3 ms 848 KB Output is correct
117 Correct 13 ms 2384 KB Output is correct
118 Correct 14 ms 2508 KB Output is correct
119 Correct 39 ms 5548 KB Output is correct
120 Correct 33 ms 5480 KB Output is correct
121 Correct 32 ms 5580 KB Output is correct
122 Correct 31 ms 5572 KB Output is correct
123 Correct 13 ms 2760 KB Output is correct
124 Correct 28 ms 4868 KB Output is correct
125 Correct 43 ms 5452 KB Output is correct
126 Correct 32 ms 5572 KB Output is correct
127 Correct 27 ms 4556 KB Output is correct
128 Correct 12 ms 2296 KB Output is correct