Submission #198676

# Submission time Handle Problem Language Result Execution time Memory
198676 2020-01-27T09:12:24 Z Nightlight Vision Program (IOI19_vision) C++14
100 / 100
51 ms 4856 KB
#include "vision.h"
#include <bits/stdc++.h>
#define eb emplace_back
using namespace std;

typedef pair<int, int> pii;
int R[405], L[405];
int diag[2][405], A[205][205];
int H, W, K, cnt;
int maxk;
vector<int> ask, all;
//diagonal jika 0 menghadap ke kanan, 1 menghadap ke kiri

void compress() {
  vector<int> diag0[H + W], diag1[H + W];
  cnt = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      diag0[i + j].eb(cnt);
      diag1[(H - i - 1) + j].eb(cnt);
      A[i][j] = cnt++;
    }
  }
/*
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cout << i + j << " ";
    }
    cout << "\n";
  }
  cout << "\n\n";
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cout << (H - i - 1) + j << " ";
    }
    cout << "\n";
  }
  cout << "\n\n";
*/
  for(int i = 0; i < maxk; i++) {
    add_or(diag0[i]);
    diag[0][i] = cnt++;
    add_or(diag1[i]);
    diag[1][i] = cnt++;
  }
}

void add() {
  add_or(ask);
  add_xor(ask);
  add_not(cnt + 1);
  add_and({cnt, cnt + 2});
  all.eb(cnt + 3);
  cnt += 4;
}

int check(int len, int id) {
  //sliding window
  ask.clear(), all.clear();
  ask.resize(len);
  int p = 0;
  for(int i = 0; i < len; i++) {
    ask[i] = diag[id][i];
  }
  add();
  for(int i = len; i < maxk; i++) {
    ask[p] = diag[id][i], p = (p + 1) % len;
    add();
  }
  add_or(all), cnt++;
  return cnt - 1;
}

int getlen(int len) {
  R[len] = check(len + 1, 0);
  L[len] = check(len + 1, 1);
  add_and({R[len], L[len]}), cnt++;
  return cnt - 1;
}

void solve() {
  int valK = getlen(K);
  int valK1 = getlen(K - 1);
  add_not(valK1);
  add_and({valK, valK1 + 1});
  int com = cnt + 1;
  cnt += 2;
  //special case
  vector<int> tmp;
  tmp.resize(maxk);
  //right
  for(int i = 0; i < maxk; i++) {
    tmp[i] = diag[0][i];
  }
  add_xor(tmp);
  add_not(L[K - 1]);
  add_and({cnt, cnt + 1, L[K]});
  cnt += 3;
  int right = cnt - 1;
  //left
  for(int i = 0; i < maxk; i++) {
    tmp[i] = diag[1][i];
  }
  add_xor(tmp);
  add_not(R[K - 1]);
  add_and({cnt, cnt + 1, R[K]});
  cnt += 3;
  int left = cnt - 1;
  add_or({com, left, right});
}

void construct_network(int a1, int a2, int a3) {
  H = a1, W = a2, K = a3;
  maxk = H + W - 1;
  compress();
  solve();
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 380 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 380 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 7 ms 504 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 7 ms 376 KB Output is correct
32 Correct 6 ms 376 KB Output is correct
33 Correct 6 ms 504 KB Output is correct
34 Correct 7 ms 428 KB Output is correct
35 Correct 7 ms 504 KB Output is correct
36 Correct 6 ms 376 KB Output is correct
37 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 380 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 7 ms 504 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 7 ms 376 KB Output is correct
32 Correct 6 ms 376 KB Output is correct
33 Correct 6 ms 504 KB Output is correct
34 Correct 7 ms 428 KB Output is correct
35 Correct 7 ms 504 KB Output is correct
36 Correct 6 ms 376 KB Output is correct
37 Correct 6 ms 376 KB Output is correct
38 Correct 16 ms 1400 KB Output is correct
39 Correct 8 ms 504 KB Output is correct
40 Correct 7 ms 504 KB Output is correct
41 Correct 8 ms 760 KB Output is correct
42 Correct 7 ms 508 KB Output is correct
43 Correct 10 ms 1016 KB Output is correct
44 Correct 15 ms 1400 KB Output is correct
45 Correct 22 ms 1528 KB Output is correct
46 Correct 14 ms 1272 KB Output is correct
47 Correct 8 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 632 KB Output is correct
2 Correct 15 ms 1144 KB Output is correct
3 Correct 17 ms 1144 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 7 ms 760 KB Output is correct
6 Correct 14 ms 1272 KB Output is correct
7 Correct 14 ms 1144 KB Output is correct
8 Correct 6 ms 504 KB Output is correct
9 Correct 8 ms 632 KB Output is correct
10 Correct 13 ms 1016 KB Output is correct
11 Correct 15 ms 1144 KB Output is correct
12 Correct 14 ms 1140 KB Output is correct
13 Correct 13 ms 888 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 8 ms 760 KB Output is correct
16 Correct 13 ms 1144 KB Output is correct
17 Correct 14 ms 1272 KB Output is correct
18 Correct 15 ms 1272 KB Output is correct
19 Correct 12 ms 1016 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 7 ms 760 KB Output is correct
4 Correct 10 ms 760 KB Output is correct
5 Correct 12 ms 888 KB Output is correct
6 Correct 10 ms 760 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 8 ms 760 KB Output is correct
9 Correct 13 ms 1144 KB Output is correct
10 Correct 15 ms 1148 KB Output is correct
11 Correct 13 ms 1016 KB Output is correct
12 Correct 7 ms 632 KB Output is correct
13 Correct 7 ms 632 KB Output is correct
14 Correct 13 ms 1144 KB Output is correct
15 Correct 13 ms 1016 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 8 ms 760 KB Output is correct
18 Correct 36 ms 1276 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 14 ms 1396 KB Output is correct
21 Correct 29 ms 2680 KB Output is correct
22 Correct 29 ms 2680 KB Output is correct
23 Correct 11 ms 1144 KB Output is correct
24 Correct 13 ms 1268 KB Output is correct
25 Correct 31 ms 2808 KB Output is correct
26 Correct 11 ms 1016 KB Output is correct
27 Correct 18 ms 2168 KB Output is correct
28 Correct 42 ms 4088 KB Output is correct
29 Correct 49 ms 4728 KB Output is correct
30 Correct 39 ms 3832 KB Output is correct
31 Correct 16 ms 1796 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2168 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 7 ms 760 KB Output is correct
4 Correct 8 ms 760 KB Output is correct
5 Correct 7 ms 632 KB Output is correct
6 Correct 7 ms 760 KB Output is correct
7 Correct 13 ms 1396 KB Output is correct
8 Correct 13 ms 1268 KB Output is correct
9 Correct 21 ms 2168 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 380 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 7 ms 504 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 7 ms 376 KB Output is correct
32 Correct 6 ms 376 KB Output is correct
33 Correct 6 ms 504 KB Output is correct
34 Correct 7 ms 428 KB Output is correct
35 Correct 7 ms 504 KB Output is correct
36 Correct 6 ms 376 KB Output is correct
37 Correct 6 ms 376 KB Output is correct
38 Correct 16 ms 1400 KB Output is correct
39 Correct 8 ms 504 KB Output is correct
40 Correct 7 ms 504 KB Output is correct
41 Correct 8 ms 760 KB Output is correct
42 Correct 7 ms 508 KB Output is correct
43 Correct 10 ms 1016 KB Output is correct
44 Correct 15 ms 1400 KB Output is correct
45 Correct 22 ms 1528 KB Output is correct
46 Correct 14 ms 1272 KB Output is correct
47 Correct 8 ms 760 KB Output is correct
48 Correct 7 ms 632 KB Output is correct
49 Correct 15 ms 1144 KB Output is correct
50 Correct 17 ms 1144 KB Output is correct
51 Correct 6 ms 376 KB Output is correct
52 Correct 7 ms 760 KB Output is correct
53 Correct 14 ms 1272 KB Output is correct
54 Correct 14 ms 1144 KB Output is correct
55 Correct 6 ms 504 KB Output is correct
56 Correct 8 ms 632 KB Output is correct
57 Correct 13 ms 1016 KB Output is correct
58 Correct 15 ms 1144 KB Output is correct
59 Correct 14 ms 1140 KB Output is correct
60 Correct 13 ms 888 KB Output is correct
61 Correct 6 ms 376 KB Output is correct
62 Correct 8 ms 760 KB Output is correct
63 Correct 13 ms 1144 KB Output is correct
64 Correct 14 ms 1272 KB Output is correct
65 Correct 15 ms 1272 KB Output is correct
66 Correct 12 ms 1016 KB Output is correct
67 Correct 6 ms 504 KB Output is correct
68 Correct 5 ms 376 KB Output is correct
69 Correct 5 ms 504 KB Output is correct
70 Correct 6 ms 504 KB Output is correct
71 Correct 5 ms 376 KB Output is correct
72 Correct 7 ms 760 KB Output is correct
73 Correct 10 ms 760 KB Output is correct
74 Correct 12 ms 888 KB Output is correct
75 Correct 10 ms 760 KB Output is correct
76 Correct 7 ms 504 KB Output is correct
77 Correct 8 ms 760 KB Output is correct
78 Correct 13 ms 1144 KB Output is correct
79 Correct 15 ms 1148 KB Output is correct
80 Correct 13 ms 1016 KB Output is correct
81 Correct 7 ms 632 KB Output is correct
82 Correct 7 ms 632 KB Output is correct
83 Correct 13 ms 1144 KB Output is correct
84 Correct 13 ms 1016 KB Output is correct
85 Correct 6 ms 376 KB Output is correct
86 Correct 8 ms 760 KB Output is correct
87 Correct 36 ms 1276 KB Output is correct
88 Correct 6 ms 504 KB Output is correct
89 Correct 14 ms 1396 KB Output is correct
90 Correct 29 ms 2680 KB Output is correct
91 Correct 29 ms 2680 KB Output is correct
92 Correct 11 ms 1144 KB Output is correct
93 Correct 13 ms 1268 KB Output is correct
94 Correct 31 ms 2808 KB Output is correct
95 Correct 11 ms 1016 KB Output is correct
96 Correct 18 ms 2168 KB Output is correct
97 Correct 42 ms 4088 KB Output is correct
98 Correct 49 ms 4728 KB Output is correct
99 Correct 39 ms 3832 KB Output is correct
100 Correct 16 ms 1796 KB Output is correct
101 Correct 5 ms 376 KB Output is correct
102 Correct 5 ms 376 KB Output is correct
103 Correct 19 ms 2168 KB Output is correct
104 Correct 5 ms 376 KB Output is correct
105 Correct 7 ms 760 KB Output is correct
106 Correct 8 ms 760 KB Output is correct
107 Correct 7 ms 632 KB Output is correct
108 Correct 7 ms 760 KB Output is correct
109 Correct 13 ms 1396 KB Output is correct
110 Correct 13 ms 1268 KB Output is correct
111 Correct 21 ms 2168 KB Output is correct
112 Correct 5 ms 376 KB Output is correct
113 Correct 5 ms 376 KB Output is correct
114 Correct 41 ms 4088 KB Output is correct
115 Correct 6 ms 376 KB Output is correct
116 Correct 10 ms 760 KB Output is correct
117 Correct 21 ms 2028 KB Output is correct
118 Correct 23 ms 2164 KB Output is correct
119 Correct 48 ms 4732 KB Output is correct
120 Correct 48 ms 4728 KB Output is correct
121 Correct 49 ms 4728 KB Output is correct
122 Correct 49 ms 4728 KB Output is correct
123 Correct 18 ms 2168 KB Output is correct
124 Correct 43 ms 4088 KB Output is correct
125 Correct 51 ms 4856 KB Output is correct
126 Correct 48 ms 4728 KB Output is correct
127 Correct 39 ms 3832 KB Output is correct
128 Correct 16 ms 1784 KB Output is correct