Submission #600307

# Submission time Handle Problem Language Result Execution time Memory
600307 2022-07-20T17:30:01 Z Sam_a17 Vision Program (IOI19_vision) C++14
100 / 100
246 ms 10936 KB
#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int((x).size()))
#define len(x) (int)x.length()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dbg(x) cerr << #x << " " << x << endl;

#define pb push_back
#define ld long double
#define ll long long

int add_and(std::vector<int> Ns);
int add_or(std::vector<int> Ns);
int add_xor(std::vector<int> Ns);
int add_not(int N);

void pr(vector<int>& a) {
  cerr << "[ ";
  for(auto i: a) {
    cerr << i << " ";
  }
  cerr << "]" << endl;
}

void pr(deque<int>& a) {
  cerr << "[ ";
  for(auto i: a) {
    cerr << i << " ";
  }
  cerr << "]" << endl;
}

const int N = 205, M = 1e5 + 10;
int a[N][N];

int lxor[M], rxor[M];
int lor[M], ror[M];

vector<int> rows[M], cols[M];

void construct_network(int H, int W, int K) {
  
  int cnt = H * W, qn = 0;
  int n = H, m = W;

  vector<pair<int, int>> diag;


  //
  for(int i = m - 1; i >= 0; i--) {
    int x = 0, y = i;
    while(x < H && y < W) {
      rows[qn].push_back(x * W + y);
      x++, y++;
    }

    add_or(rows[qn]);
    add_xor(rows[qn]); 
    
    ror[qn] = cnt;
    rxor[qn] = cnt + 1;
    
    cnt += 2;
    qn++;
  }
  
  //
  for(int i = 1; i < n; i++) {
    int x = i, y = 0;
    while(x < H && y < W) {
      rows[qn].push_back(x * W + y);
      x++, y++;
    }

    add_or(rows[qn]);
    add_xor(rows[qn]); 
    
    ror[qn] = cnt;
    rxor[qn] = cnt + 1;
    
    cnt += 2;
    qn++;
  }

  dbg(qn)
  //
  qn = 0;
  for(int i = 0; i < m; i++) {
    int x = 0, y = i;
    while(x < n && y >= 0) {
      cols[qn].push_back(x * W + y);
      x++, y--;
    }

    add_or(cols[qn]);
    add_xor(cols[qn]); 
    
    lor[qn] = cnt;
    lxor[qn] = cnt + 1;
    
    cnt += 2;
    qn++;
  }
  
  //
  for(int i = 1; i < n; i++) {
    int x = i, y = m - 1;
    while(x < n && y >= 0) {
      cols[qn].push_back(x * W + y);
      x++, y--;
    }

    add_or(cols[qn]);
    add_xor(cols[qn]); 
    
    lor[qn] = cnt;
    lxor[qn] = cnt + 1;

    cnt += 2;
    qn++;
  }
  dbg(qn)


  auto slidingWindow = [&](int ki)->int {
    vector<int> answ1, answ2;
    for(int i = 0; i + ki < n + m - 1; i++) {
      vector<int> askii, askii2;  
      for(int j = i; j <= i + ki; j++) {
        askii.push_back(ror[j]);
        askii2.push_back(rxor[j]);
      }

      pr(askii);

      add_or(askii);
      add_xor(askii2);
      add_xor({cnt, cnt + 1});
      answ1.push_back(cnt + 2);
      cnt += 3;


      askii.clear(), askii2.clear();
      for(int j = i; j <= i + ki; j++) {
        askii.push_back(lor[j]);
        askii2.push_back(lxor[j]);
      }

      add_or(askii);
      add_xor(askii2);
      add_xor({cnt, cnt + 1});
      answ2.push_back(cnt + 2);
      cnt += 3;
    }

    add_or(answ1);
    cnt++;
    
    add_or(answ2);
    cnt++;

    add_and({cnt - 1, cnt - 2});
    cnt++;
    return cnt - 1;
  };
  
  
  if(K == 1) {
    int s1 = slidingWindow(1);
    int s2 = slidingWindow(1);
    add_and({s1, s2});
  } else {
    add_xor({slidingWindow(K - 1), slidingWindow(K)});
  }

}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5076 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 4 ms 5004 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 3 ms 5004 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 3 ms 5008 KB Output is correct
14 Correct 3 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5076 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 4 ms 5004 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 3 ms 5004 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 3 ms 5008 KB Output is correct
14 Correct 3 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 4 ms 4948 KB Output is correct
21 Correct 4 ms 5000 KB Output is correct
22 Correct 4 ms 5012 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 4948 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 4 ms 5008 KB Output is correct
27 Correct 3 ms 5008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5076 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 4 ms 5004 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 3 ms 5004 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 3 ms 5008 KB Output is correct
14 Correct 3 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 4 ms 4948 KB Output is correct
21 Correct 4 ms 5000 KB Output is correct
22 Correct 4 ms 5012 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 4948 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 4 ms 5008 KB Output is correct
27 Correct 3 ms 5008 KB Output is correct
28 Correct 8 ms 5116 KB Output is correct
29 Correct 4 ms 4948 KB Output is correct
30 Correct 6 ms 5012 KB Output is correct
31 Correct 3 ms 4948 KB Output is correct
32 Correct 4 ms 5076 KB Output is correct
33 Correct 5 ms 5076 KB Output is correct
34 Correct 8 ms 5136 KB Output is correct
35 Correct 9 ms 5132 KB Output is correct
36 Correct 7 ms 5076 KB Output is correct
37 Correct 5 ms 5008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5076 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 4 ms 5004 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 3 ms 5004 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 3 ms 5008 KB Output is correct
14 Correct 3 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 4 ms 4948 KB Output is correct
21 Correct 4 ms 5000 KB Output is correct
22 Correct 4 ms 5012 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 4948 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 4 ms 5008 KB Output is correct
27 Correct 3 ms 5008 KB Output is correct
28 Correct 8 ms 5116 KB Output is correct
29 Correct 4 ms 4948 KB Output is correct
30 Correct 6 ms 5012 KB Output is correct
31 Correct 3 ms 4948 KB Output is correct
32 Correct 4 ms 5076 KB Output is correct
33 Correct 5 ms 5076 KB Output is correct
34 Correct 8 ms 5136 KB Output is correct
35 Correct 9 ms 5132 KB Output is correct
36 Correct 7 ms 5076 KB Output is correct
37 Correct 5 ms 5008 KB Output is correct
38 Correct 46 ms 6300 KB Output is correct
39 Correct 13 ms 5204 KB Output is correct
40 Correct 13 ms 5204 KB Output is correct
41 Correct 9 ms 5388 KB Output is correct
42 Correct 9 ms 5264 KB Output is correct
43 Correct 11 ms 5716 KB Output is correct
44 Correct 47 ms 6320 KB Output is correct
45 Correct 59 ms 6440 KB Output is correct
46 Correct 47 ms 6144 KB Output is correct
47 Correct 8 ms 5512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 5204 KB Output is correct
2 Correct 56 ms 5800 KB Output is correct
3 Correct 70 ms 5772 KB Output is correct
4 Correct 5 ms 5076 KB Output is correct
5 Correct 10 ms 5204 KB Output is correct
6 Correct 53 ms 5732 KB Output is correct
7 Correct 50 ms 5692 KB Output is correct
8 Correct 6 ms 5076 KB Output is correct
9 Correct 9 ms 5260 KB Output is correct
10 Correct 43 ms 5708 KB Output is correct
11 Correct 57 ms 5844 KB Output is correct
12 Correct 54 ms 5804 KB Output is correct
13 Correct 42 ms 5580 KB Output is correct
14 Correct 5 ms 5076 KB Output is correct
15 Correct 8 ms 5260 KB Output is correct
16 Correct 52 ms 5664 KB Output is correct
17 Correct 54 ms 5836 KB Output is correct
18 Correct 55 ms 5800 KB Output is correct
19 Correct 44 ms 5640 KB Output is correct
20 Correct 5 ms 5076 KB Output is correct
21 Correct 3 ms 5004 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5000 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 7 ms 5332 KB Output is correct
4 Correct 21 ms 5432 KB Output is correct
5 Correct 26 ms 5544 KB Output is correct
6 Correct 22 ms 5380 KB Output is correct
7 Correct 5 ms 5204 KB Output is correct
8 Correct 10 ms 5520 KB Output is correct
9 Correct 38 ms 5852 KB Output is correct
10 Correct 49 ms 5948 KB Output is correct
11 Correct 39 ms 5820 KB Output is correct
12 Correct 7 ms 5264 KB Output is correct
13 Correct 7 ms 5264 KB Output is correct
14 Correct 49 ms 5752 KB Output is correct
15 Correct 48 ms 5688 KB Output is correct
16 Correct 5 ms 5012 KB Output is correct
17 Correct 7 ms 5204 KB Output is correct
18 Correct 59 ms 5780 KB Output is correct
19 Correct 6 ms 5076 KB Output is correct
20 Correct 21 ms 6456 KB Output is correct
21 Correct 120 ms 8048 KB Output is correct
22 Correct 115 ms 7864 KB Output is correct
23 Correct 16 ms 6028 KB Output is correct
24 Correct 17 ms 6348 KB Output is correct
25 Correct 152 ms 8132 KB Output is correct
26 Correct 12 ms 6028 KB Output is correct
27 Correct 25 ms 7428 KB Output is correct
28 Correct 196 ms 10072 KB Output is correct
29 Correct 236 ms 10920 KB Output is correct
30 Correct 178 ms 9868 KB Output is correct
31 Correct 23 ms 7088 KB Output is correct
32 Correct 3 ms 4948 KB Output is correct
33 Correct 3 ms 5008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 7436 KB Output is correct
2 Correct 3 ms 5012 KB Output is correct
3 Correct 7 ms 5332 KB Output is correct
4 Correct 9 ms 5460 KB Output is correct
5 Correct 8 ms 5204 KB Output is correct
6 Correct 9 ms 5204 KB Output is correct
7 Correct 18 ms 6272 KB Output is correct
8 Correct 17 ms 6292 KB Output is correct
9 Correct 26 ms 7484 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 5076 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 4 ms 5004 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 3 ms 5004 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 3 ms 5008 KB Output is correct
14 Correct 3 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 4 ms 4948 KB Output is correct
21 Correct 4 ms 5000 KB Output is correct
22 Correct 4 ms 5012 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 4948 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 4 ms 5008 KB Output is correct
27 Correct 3 ms 5008 KB Output is correct
28 Correct 8 ms 5116 KB Output is correct
29 Correct 4 ms 4948 KB Output is correct
30 Correct 6 ms 5012 KB Output is correct
31 Correct 3 ms 4948 KB Output is correct
32 Correct 4 ms 5076 KB Output is correct
33 Correct 5 ms 5076 KB Output is correct
34 Correct 8 ms 5136 KB Output is correct
35 Correct 9 ms 5132 KB Output is correct
36 Correct 7 ms 5076 KB Output is correct
37 Correct 5 ms 5008 KB Output is correct
38 Correct 46 ms 6300 KB Output is correct
39 Correct 13 ms 5204 KB Output is correct
40 Correct 13 ms 5204 KB Output is correct
41 Correct 9 ms 5388 KB Output is correct
42 Correct 9 ms 5264 KB Output is correct
43 Correct 11 ms 5716 KB Output is correct
44 Correct 47 ms 6320 KB Output is correct
45 Correct 59 ms 6440 KB Output is correct
46 Correct 47 ms 6144 KB Output is correct
47 Correct 8 ms 5512 KB Output is correct
48 Correct 7 ms 5204 KB Output is correct
49 Correct 56 ms 5800 KB Output is correct
50 Correct 70 ms 5772 KB Output is correct
51 Correct 5 ms 5076 KB Output is correct
52 Correct 10 ms 5204 KB Output is correct
53 Correct 53 ms 5732 KB Output is correct
54 Correct 50 ms 5692 KB Output is correct
55 Correct 6 ms 5076 KB Output is correct
56 Correct 9 ms 5260 KB Output is correct
57 Correct 43 ms 5708 KB Output is correct
58 Correct 57 ms 5844 KB Output is correct
59 Correct 54 ms 5804 KB Output is correct
60 Correct 42 ms 5580 KB Output is correct
61 Correct 5 ms 5076 KB Output is correct
62 Correct 8 ms 5260 KB Output is correct
63 Correct 52 ms 5664 KB Output is correct
64 Correct 54 ms 5836 KB Output is correct
65 Correct 55 ms 5800 KB Output is correct
66 Correct 44 ms 5640 KB Output is correct
67 Correct 5 ms 5076 KB Output is correct
68 Correct 3 ms 5004 KB Output is correct
69 Correct 3 ms 4948 KB Output is correct
70 Correct 3 ms 5000 KB Output is correct
71 Correct 3 ms 4948 KB Output is correct
72 Correct 7 ms 5332 KB Output is correct
73 Correct 21 ms 5432 KB Output is correct
74 Correct 26 ms 5544 KB Output is correct
75 Correct 22 ms 5380 KB Output is correct
76 Correct 5 ms 5204 KB Output is correct
77 Correct 10 ms 5520 KB Output is correct
78 Correct 38 ms 5852 KB Output is correct
79 Correct 49 ms 5948 KB Output is correct
80 Correct 39 ms 5820 KB Output is correct
81 Correct 7 ms 5264 KB Output is correct
82 Correct 7 ms 5264 KB Output is correct
83 Correct 49 ms 5752 KB Output is correct
84 Correct 48 ms 5688 KB Output is correct
85 Correct 5 ms 5012 KB Output is correct
86 Correct 7 ms 5204 KB Output is correct
87 Correct 59 ms 5780 KB Output is correct
88 Correct 6 ms 5076 KB Output is correct
89 Correct 21 ms 6456 KB Output is correct
90 Correct 120 ms 8048 KB Output is correct
91 Correct 115 ms 7864 KB Output is correct
92 Correct 16 ms 6028 KB Output is correct
93 Correct 17 ms 6348 KB Output is correct
94 Correct 152 ms 8132 KB Output is correct
95 Correct 12 ms 6028 KB Output is correct
96 Correct 25 ms 7428 KB Output is correct
97 Correct 196 ms 10072 KB Output is correct
98 Correct 236 ms 10920 KB Output is correct
99 Correct 178 ms 9868 KB Output is correct
100 Correct 23 ms 7088 KB Output is correct
101 Correct 3 ms 4948 KB Output is correct
102 Correct 3 ms 5008 KB Output is correct
103 Correct 26 ms 7436 KB Output is correct
104 Correct 3 ms 5012 KB Output is correct
105 Correct 7 ms 5332 KB Output is correct
106 Correct 9 ms 5460 KB Output is correct
107 Correct 8 ms 5204 KB Output is correct
108 Correct 9 ms 5204 KB Output is correct
109 Correct 18 ms 6272 KB Output is correct
110 Correct 17 ms 6292 KB Output is correct
111 Correct 26 ms 7484 KB Output is correct
112 Correct 3 ms 4948 KB Output is correct
113 Correct 3 ms 4948 KB Output is correct
114 Correct 175 ms 10044 KB Output is correct
115 Correct 6 ms 5076 KB Output is correct
116 Correct 9 ms 5264 KB Output is correct
117 Correct 88 ms 7108 KB Output is correct
118 Correct 82 ms 7348 KB Output is correct
119 Correct 232 ms 10828 KB Output is correct
120 Correct 230 ms 10892 KB Output is correct
121 Correct 231 ms 10828 KB Output is correct
122 Correct 229 ms 10864 KB Output is correct
123 Correct 26 ms 7548 KB Output is correct
124 Correct 182 ms 10136 KB Output is correct
125 Correct 238 ms 10936 KB Output is correct
126 Correct 246 ms 10872 KB Output is correct
127 Correct 175 ms 9936 KB Output is correct
128 Correct 20 ms 7172 KB Output is correct