// correct/felix-full-original-fixed.cpp
#include<bits/stdc++.h>
#include "hieroglyphs.h"
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
//erases non-common elements
void clean(vi& a, vi& b) {
vi ap;
vi bp;
set<int> as;
set<int> bs;
for (int x : a) as.insert(x);
for (int x : b) bs.insert(x);
for (int x : a) if (bs.count(x)) ap.push_back(x);
for (int x : b) if (as.count(x)) bp.push_back(x);
swap(a, ap);
swap(b, bp);
}
map<int, int> coordinate_compress(vi& a, vi& b) {
int cc = 0;
map<int, int> mp;
map<int, int> rmp;
for (int& x : a) {
if (!mp.count(x)) {
mp[x] = cc++;
rmp[mp[x]] = x;
}
x = mp[x];
}
for (int& x : b) {
if (!mp.count(x)) {
mp[x] = cc++;
rmp[mp[x]] = x;
}
x = mp[x];
}
return rmp;
}
bool is_subsequence(const vi& a, const vi& b) {
int j = 0;
for (int x : a) {
if (j < (int)b.size() && b[j] == x) {
j++;
}
}
return j == (int)b.size();
}
vector<int> get_candidate(vector<int> a, vector<int> b) {
int n = a.size();
int m = b.size();
vi occ_a(max(n, m)+1, 0);
vi occ_b(max(n, m)+1, 0);
for (int i=0; i < n; ++i) {
occ_a[a[i]]++;
}
for (int i=0; i < m; ++i) {
occ_b[b[i]]++;
}
vi c;
queue<int> qa;
queue<int> qb;
for (int i=0; i < n; ++i) {
if (occ_a[a[i]] <= occ_b[a[i]]) {
qa.push(i);
}
}
for (int i=0; i < m; ++i) {
if (occ_a[b[i]] > occ_b[b[i]]) {
qb.push(i);
}
}
int i_a_curr = 0;
int i_b_curr = 0;
int i_a_next = 0;
int i_b_next = 0;
vi occ_a_curr = vi(occ_a);
vi occ_a_next = vi(occ_a);
vi occ_b_curr = vi(occ_b);
vi occ_b_next = vi(occ_b);
while(!qa.empty() && !qb.empty()) {
while(i_a_next < qa.front()) {
occ_a_next[a[i_a_next]]--;
i_a_next++;
}
while(i_b_next < qb.front()) {
occ_b_next[b[i_b_next]]--;
i_b_next++;
}
int x = a[i_a_next];
int y = b[i_b_next];
int occ_x = occ_a_next[x];
int occ_y = occ_b_next[y];
bool a_good = (occ_a_next[y] >= occ_y && occ_b_curr[x] > occ_b_next[x]);
bool b_good = (occ_b_next[x] >= occ_x && occ_a_curr[y] > occ_a_next[y]);
if (a_good && b_good) return vi();
if (!a_good && !b_good) return vi();
if(a_good) {
c.push_back(x);
qa.pop();
while(i_a_curr <= i_a_next) {
occ_a_curr[a[i_a_curr]]--;
i_a_curr++;
}
while(b[i_b_curr] != x) {
occ_b_curr[b[i_b_curr]]--;
i_b_curr++;
}
occ_b_curr[b[i_b_curr]]--;
i_b_curr++;
}
else {
c.push_back(y);
qb.pop();
while(i_b_curr <= i_b_next) {
occ_b_curr[b[i_b_curr]]--;
i_b_curr++;
}
while(a[i_a_curr] != y) {
occ_a_curr[a[i_a_curr]]--;
i_a_curr++;
}
occ_a_curr[a[i_a_curr]]--;
i_a_curr++;
}
}
while(!qa.empty()) {
c.push_back(a[qa.front()]);
qa.pop();
}
while(!qb.empty()) {
c.push_back(b[qb.front()]);
qb.pop();
}
return ((is_subsequence(a, c) && is_subsequence(b, c)) ? c : vi());
}
//returns v of size |b|
//v[i] = smallest index so that there exists a common subsequence of a[0..v[i]] and b[0..i] that is not
// a common subsequence of a[0..v[i]] and b[0..i-1]. if such index does not exist, v[i] = |a|
vector<int> index_vector(const vi& a, const vi& b) {
int n = a.size();
int m = b.size();
vi v(m);
int max_v = 0;
for (int x : a) max_v = max(x, max_v);
for (int x : b) max_v = max(x, max_v);
vi prev_occ_b(max_v+1, -1);
vvi a_occ(max_v+1);
for (int i=0; i < n; ++i) {
a_occ[a[i]].push_back(i);
}
for (int i=0; i <= max_v; ++i) {
a_occ[i].push_back(n);
}
vector<pair<int, int>> min_stack;
for (int i=0; i < m; ++i) {
if (prev_occ_b[b[i]] == -1) {
v[i] = a_occ[b[i]][0];
}
else {
int min_val = lower_bound(min_stack.begin(), min_stack.end(), pair<int, int>(prev_occ_b[b[i]], -1))->second;
if (min_val < n) v[i] = *lower_bound(a_occ[b[i]].begin(), a_occ[b[i]].end(), min_val+1);
else v[i] = n;
}
while(!min_stack.empty() && min_stack.back().second >= v[i]) {
min_stack.pop_back();
}
min_stack.emplace_back(i, v[i]);
prev_occ_b[b[i]] = i;
}
return v;
}
// RMQ template from KACTL
template<class T>
struct RMQ {
vector<vector<T>> jmp;
RMQ(const vector<T>& V) : jmp(1, V) {
for (int pw = 1, k = 1; pw * 2 <= (int)V.size(); pw *= 2, ++k) {
jmp.emplace_back((int)V.size() - pw * 2 + 1);
for (int j=0; j < (int)jmp[k].size(); ++j)
jmp[k][j] = min(jmp[k - 1][j], jmp[k - 1][j + pw]);
}
}
T query(int a, int b) {
int dep = 31 - __builtin_clz(b - a);
return min(jmp[dep][a], jmp[dep][b - (1 << dep)]);
}
};
bool no_single_crossing(const vi& a, const vi& b, const vi& c) {
int n = a.size();
int m = b.size();
int l = c.size();
vi rb = vi(b);
reverse(rb.begin(), rb.end());
vi rc = vi(c);
reverse(rc.begin(), rc.end());
vi v_ab = index_vector(a, b);
vi v_rbc = index_vector(rb, rc);
RMQ<int> v_rbc_rmq = RMQ<int>(v_rbc);
vi v_max_rc_i(n+1);
v_max_rc_i[n] = 0;
for (int i=n-1; i >= 0; --i) {
v_max_rc_i[i] = v_max_rc_i[i+1];
if (v_max_rc_i[i+1] < l && a[i] == rc[v_max_rc_i[i+1]]) {
v_max_rc_i[i]++;
}
}
vi v_min_rc_i(m+1);
v_min_rc_i[0] = l-1;
for (int i=0; i < m; ++i) {
v_min_rc_i[i+1] = v_min_rc_i[i];
if (v_min_rc_i[i] > -1 && b[i] == rc[v_min_rc_i[i]]) {
v_min_rc_i[i+1]--;
}
}
for (int j=0; j < m; ++j) {
int ai = v_ab[j];
if (ai == n) continue;
int min_rc_i = v_min_rc_i[j+1];
int max_rc_i = v_max_rc_i[ai+1];
if (min_rc_i+1 < max_rc_i && v_rbc_rmq.query(min_rc_i+1, max_rc_i) + j < m-1) return false;
}
return true;
}
bool verify(const vi& a, const vi& b, const vi& c) {
if (c.empty()) return false;
return no_single_crossing(a, b, c) && no_single_crossing(b, a, c);
}
vector<int> ucs(vector<int> a, vector<int> b) {
clean(a, b);
if (a.empty() || b.empty()) {
return {};
}
map<int, int> mp = coordinate_compress(a, b);
vi c = get_candidate(a, b);
if (verify(a, b, c)) {
for (int& x : c) x = mp[x];
return c;
}
return {-1};
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
296 ms |
20068 KB |
Output is correct |
6 |
Correct |
271 ms |
15612 KB |
Output is correct |
7 |
Correct |
228 ms |
15664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
296 ms |
20068 KB |
Output is correct |
6 |
Correct |
271 ms |
15612 KB |
Output is correct |
7 |
Correct |
228 ms |
15664 KB |
Output is correct |
8 |
Correct |
204 ms |
12992 KB |
Output is correct |
9 |
Correct |
216 ms |
13040 KB |
Output is correct |
10 |
Correct |
218 ms |
12968 KB |
Output is correct |
11 |
Correct |
212 ms |
13076 KB |
Output is correct |
12 |
Correct |
204 ms |
13356 KB |
Output is correct |
13 |
Correct |
222 ms |
13080 KB |
Output is correct |
14 |
Correct |
202 ms |
13220 KB |
Output is correct |
15 |
Correct |
215 ms |
13176 KB |
Output is correct |
16 |
Correct |
210 ms |
13072 KB |
Output is correct |
17 |
Correct |
204 ms |
13080 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
79 ms |
7232 KB |
Output is correct |
23 |
Correct |
158 ms |
11980 KB |
Output is correct |
24 |
Correct |
142 ms |
11820 KB |
Output is correct |
25 |
Correct |
153 ms |
11980 KB |
Output is correct |
26 |
Correct |
93 ms |
6676 KB |
Output is correct |
27 |
Correct |
192 ms |
13008 KB |
Output is correct |
28 |
Correct |
233 ms |
13084 KB |
Output is correct |
29 |
Correct |
188 ms |
12972 KB |
Output is correct |
30 |
Correct |
187 ms |
13004 KB |
Output is correct |
31 |
Correct |
212 ms |
13088 KB |
Output is correct |
32 |
Correct |
173 ms |
13148 KB |
Output is correct |
33 |
Correct |
168 ms |
13000 KB |
Output is correct |
34 |
Correct |
193 ms |
11916 KB |
Output is correct |
35 |
Correct |
200 ms |
13108 KB |
Output is correct |
36 |
Correct |
199 ms |
13076 KB |
Output is correct |
37 |
Correct |
183 ms |
13076 KB |
Output is correct |
38 |
Correct |
224 ms |
13108 KB |
Output is correct |
39 |
Correct |
243 ms |
13108 KB |
Output is correct |
40 |
Correct |
199 ms |
13100 KB |
Output is correct |
41 |
Correct |
228 ms |
13148 KB |
Output is correct |
42 |
Correct |
209 ms |
13076 KB |
Output is correct |
43 |
Correct |
177 ms |
13108 KB |
Output is correct |
44 |
Correct |
214 ms |
13076 KB |
Output is correct |
45 |
Correct |
197 ms |
13028 KB |
Output is correct |
46 |
Correct |
202 ms |
13016 KB |
Output is correct |
47 |
Correct |
191 ms |
13092 KB |
Output is correct |
48 |
Correct |
199 ms |
13076 KB |
Output is correct |
49 |
Correct |
179 ms |
13100 KB |
Output is correct |
50 |
Correct |
215 ms |
13076 KB |
Output is correct |
51 |
Correct |
227 ms |
13048 KB |
Output is correct |
52 |
Correct |
163 ms |
13112 KB |
Output is correct |
53 |
Correct |
168 ms |
13080 KB |
Output is correct |
54 |
Correct |
182 ms |
13204 KB |
Output is correct |
55 |
Correct |
183 ms |
13100 KB |
Output is correct |
56 |
Correct |
221 ms |
13136 KB |
Output is correct |
57 |
Correct |
181 ms |
13100 KB |
Output is correct |
58 |
Correct |
187 ms |
13052 KB |
Output is correct |
59 |
Correct |
199 ms |
13068 KB |
Output is correct |
60 |
Correct |
202 ms |
13160 KB |
Output is correct |
61 |
Correct |
233 ms |
13216 KB |
Output is correct |
62 |
Correct |
211 ms |
12968 KB |
Output is correct |
63 |
Correct |
200 ms |
13076 KB |
Output is correct |
64 |
Correct |
205 ms |
13096 KB |
Output is correct |
65 |
Correct |
203 ms |
13136 KB |
Output is correct |
66 |
Correct |
242 ms |
13028 KB |
Output is correct |
67 |
Correct |
214 ms |
13012 KB |
Output is correct |
68 |
Correct |
188 ms |
13068 KB |
Output is correct |
69 |
Correct |
0 ms |
360 KB |
Output is correct |
70 |
Correct |
1 ms |
432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
87 ms |
10912 KB |
Output is correct |
2 |
Correct |
77 ms |
10948 KB |
Output is correct |
3 |
Correct |
63 ms |
6972 KB |
Output is correct |
4 |
Correct |
42 ms |
6784 KB |
Output is correct |
5 |
Correct |
72 ms |
9992 KB |
Output is correct |
6 |
Correct |
28 ms |
4104 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
432 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
57 ms |
9956 KB |
Output is correct |
17 |
Correct |
21 ms |
5696 KB |
Output is correct |
18 |
Correct |
31 ms |
5640 KB |
Output is correct |
19 |
Correct |
13 ms |
4868 KB |
Output is correct |
20 |
Correct |
55 ms |
7924 KB |
Output is correct |
21 |
Correct |
18 ms |
5048 KB |
Output is correct |
22 |
Correct |
27 ms |
5556 KB |
Output is correct |
23 |
Correct |
31 ms |
10932 KB |
Output is correct |
24 |
Correct |
34 ms |
11176 KB |
Output is correct |
25 |
Correct |
29 ms |
6212 KB |
Output is correct |
26 |
Correct |
37 ms |
10940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
204 ms |
12992 KB |
Output is correct |
2 |
Correct |
216 ms |
13040 KB |
Output is correct |
3 |
Correct |
218 ms |
12968 KB |
Output is correct |
4 |
Correct |
212 ms |
13076 KB |
Output is correct |
5 |
Correct |
204 ms |
13356 KB |
Output is correct |
6 |
Correct |
222 ms |
13080 KB |
Output is correct |
7 |
Correct |
202 ms |
13220 KB |
Output is correct |
8 |
Correct |
215 ms |
13176 KB |
Output is correct |
9 |
Correct |
210 ms |
13072 KB |
Output is correct |
10 |
Correct |
204 ms |
13080 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Correct |
79 ms |
7232 KB |
Output is correct |
16 |
Correct |
158 ms |
11980 KB |
Output is correct |
17 |
Correct |
142 ms |
11820 KB |
Output is correct |
18 |
Correct |
153 ms |
11980 KB |
Output is correct |
19 |
Correct |
93 ms |
6676 KB |
Output is correct |
20 |
Correct |
87 ms |
10912 KB |
Output is correct |
21 |
Correct |
77 ms |
10948 KB |
Output is correct |
22 |
Correct |
63 ms |
6972 KB |
Output is correct |
23 |
Correct |
42 ms |
6784 KB |
Output is correct |
24 |
Correct |
72 ms |
9992 KB |
Output is correct |
25 |
Correct |
28 ms |
4104 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
2 ms |
348 KB |
Output is correct |
29 |
Correct |
2 ms |
348 KB |
Output is correct |
30 |
Correct |
2 ms |
348 KB |
Output is correct |
31 |
Correct |
2 ms |
604 KB |
Output is correct |
32 |
Correct |
3 ms |
604 KB |
Output is correct |
33 |
Correct |
3 ms |
604 KB |
Output is correct |
34 |
Correct |
15 ms |
2440 KB |
Output is correct |
35 |
Correct |
58 ms |
10156 KB |
Output is correct |
36 |
Correct |
101 ms |
11028 KB |
Output is correct |
37 |
Correct |
71 ms |
11184 KB |
Output is correct |
38 |
Correct |
66 ms |
10768 KB |
Output is correct |
39 |
Correct |
66 ms |
11040 KB |
Output is correct |
40 |
Correct |
182 ms |
12172 KB |
Output is correct |
41 |
Correct |
118 ms |
9116 KB |
Output is correct |
42 |
Correct |
29 ms |
4932 KB |
Output is correct |
43 |
Correct |
31 ms |
5128 KB |
Output is correct |
44 |
Correct |
36 ms |
5128 KB |
Output is correct |
45 |
Correct |
31 ms |
4560 KB |
Output is correct |
46 |
Correct |
163 ms |
9500 KB |
Output is correct |
47 |
Correct |
161 ms |
9516 KB |
Output is correct |
48 |
Correct |
181 ms |
9528 KB |
Output is correct |
49 |
Correct |
172 ms |
8860 KB |
Output is correct |
50 |
Correct |
168 ms |
8972 KB |
Output is correct |
51 |
Correct |
171 ms |
8868 KB |
Output is correct |
52 |
Correct |
189 ms |
8376 KB |
Output is correct |
53 |
Correct |
156 ms |
8332 KB |
Output is correct |
54 |
Correct |
141 ms |
8248 KB |
Output is correct |
55 |
Correct |
19 ms |
2460 KB |
Output is correct |
56 |
Correct |
78 ms |
11044 KB |
Output is correct |
57 |
Correct |
63 ms |
9824 KB |
Output is correct |
58 |
Correct |
90 ms |
11556 KB |
Output is correct |
59 |
Correct |
134 ms |
10972 KB |
Output is correct |
60 |
Correct |
152 ms |
10420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
432 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
3 ms |
604 KB |
Output is correct |
17 |
Correct |
3 ms |
604 KB |
Output is correct |
18 |
Correct |
3 ms |
604 KB |
Output is correct |
19 |
Correct |
3 ms |
604 KB |
Output is correct |
20 |
Correct |
3 ms |
604 KB |
Output is correct |
21 |
Correct |
4 ms |
604 KB |
Output is correct |
22 |
Correct |
3 ms |
600 KB |
Output is correct |
23 |
Correct |
3 ms |
736 KB |
Output is correct |
24 |
Correct |
4 ms |
604 KB |
Output is correct |
25 |
Correct |
4 ms |
604 KB |
Output is correct |
26 |
Correct |
4 ms |
604 KB |
Output is correct |
27 |
Correct |
3 ms |
604 KB |
Output is correct |
28 |
Correct |
4 ms |
604 KB |
Output is correct |
29 |
Correct |
2 ms |
496 KB |
Output is correct |
30 |
Correct |
2 ms |
600 KB |
Output is correct |
31 |
Correct |
3 ms |
600 KB |
Output is correct |
32 |
Correct |
2 ms |
604 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
1 ms |
348 KB |
Output is correct |
38 |
Correct |
1 ms |
348 KB |
Output is correct |
39 |
Correct |
2 ms |
348 KB |
Output is correct |
40 |
Correct |
1 ms |
348 KB |
Output is correct |
41 |
Correct |
1 ms |
348 KB |
Output is correct |
42 |
Correct |
2 ms |
604 KB |
Output is correct |
43 |
Correct |
1 ms |
604 KB |
Output is correct |
44 |
Correct |
2 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
296 ms |
20068 KB |
Output is correct |
9 |
Correct |
271 ms |
15612 KB |
Output is correct |
10 |
Correct |
228 ms |
15664 KB |
Output is correct |
11 |
Correct |
204 ms |
12992 KB |
Output is correct |
12 |
Correct |
216 ms |
13040 KB |
Output is correct |
13 |
Correct |
218 ms |
12968 KB |
Output is correct |
14 |
Correct |
212 ms |
13076 KB |
Output is correct |
15 |
Correct |
204 ms |
13356 KB |
Output is correct |
16 |
Correct |
222 ms |
13080 KB |
Output is correct |
17 |
Correct |
202 ms |
13220 KB |
Output is correct |
18 |
Correct |
215 ms |
13176 KB |
Output is correct |
19 |
Correct |
210 ms |
13072 KB |
Output is correct |
20 |
Correct |
204 ms |
13080 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
2 ms |
604 KB |
Output is correct |
25 |
Correct |
79 ms |
7232 KB |
Output is correct |
26 |
Correct |
158 ms |
11980 KB |
Output is correct |
27 |
Correct |
142 ms |
11820 KB |
Output is correct |
28 |
Correct |
153 ms |
11980 KB |
Output is correct |
29 |
Correct |
93 ms |
6676 KB |
Output is correct |
30 |
Correct |
192 ms |
13008 KB |
Output is correct |
31 |
Correct |
233 ms |
13084 KB |
Output is correct |
32 |
Correct |
188 ms |
12972 KB |
Output is correct |
33 |
Correct |
187 ms |
13004 KB |
Output is correct |
34 |
Correct |
212 ms |
13088 KB |
Output is correct |
35 |
Correct |
173 ms |
13148 KB |
Output is correct |
36 |
Correct |
168 ms |
13000 KB |
Output is correct |
37 |
Correct |
193 ms |
11916 KB |
Output is correct |
38 |
Correct |
200 ms |
13108 KB |
Output is correct |
39 |
Correct |
199 ms |
13076 KB |
Output is correct |
40 |
Correct |
183 ms |
13076 KB |
Output is correct |
41 |
Correct |
224 ms |
13108 KB |
Output is correct |
42 |
Correct |
243 ms |
13108 KB |
Output is correct |
43 |
Correct |
199 ms |
13100 KB |
Output is correct |
44 |
Correct |
228 ms |
13148 KB |
Output is correct |
45 |
Correct |
209 ms |
13076 KB |
Output is correct |
46 |
Correct |
177 ms |
13108 KB |
Output is correct |
47 |
Correct |
214 ms |
13076 KB |
Output is correct |
48 |
Correct |
197 ms |
13028 KB |
Output is correct |
49 |
Correct |
202 ms |
13016 KB |
Output is correct |
50 |
Correct |
191 ms |
13092 KB |
Output is correct |
51 |
Correct |
199 ms |
13076 KB |
Output is correct |
52 |
Correct |
179 ms |
13100 KB |
Output is correct |
53 |
Correct |
215 ms |
13076 KB |
Output is correct |
54 |
Correct |
227 ms |
13048 KB |
Output is correct |
55 |
Correct |
163 ms |
13112 KB |
Output is correct |
56 |
Correct |
168 ms |
13080 KB |
Output is correct |
57 |
Correct |
182 ms |
13204 KB |
Output is correct |
58 |
Correct |
183 ms |
13100 KB |
Output is correct |
59 |
Correct |
221 ms |
13136 KB |
Output is correct |
60 |
Correct |
181 ms |
13100 KB |
Output is correct |
61 |
Correct |
187 ms |
13052 KB |
Output is correct |
62 |
Correct |
199 ms |
13068 KB |
Output is correct |
63 |
Correct |
202 ms |
13160 KB |
Output is correct |
64 |
Correct |
233 ms |
13216 KB |
Output is correct |
65 |
Correct |
211 ms |
12968 KB |
Output is correct |
66 |
Correct |
200 ms |
13076 KB |
Output is correct |
67 |
Correct |
205 ms |
13096 KB |
Output is correct |
68 |
Correct |
203 ms |
13136 KB |
Output is correct |
69 |
Correct |
242 ms |
13028 KB |
Output is correct |
70 |
Correct |
214 ms |
13012 KB |
Output is correct |
71 |
Correct |
188 ms |
13068 KB |
Output is correct |
72 |
Correct |
0 ms |
360 KB |
Output is correct |
73 |
Correct |
1 ms |
432 KB |
Output is correct |
74 |
Correct |
87 ms |
10912 KB |
Output is correct |
75 |
Correct |
77 ms |
10948 KB |
Output is correct |
76 |
Correct |
63 ms |
6972 KB |
Output is correct |
77 |
Correct |
42 ms |
6784 KB |
Output is correct |
78 |
Correct |
72 ms |
9992 KB |
Output is correct |
79 |
Correct |
28 ms |
4104 KB |
Output is correct |
80 |
Correct |
1 ms |
348 KB |
Output is correct |
81 |
Correct |
0 ms |
348 KB |
Output is correct |
82 |
Correct |
1 ms |
348 KB |
Output is correct |
83 |
Correct |
0 ms |
432 KB |
Output is correct |
84 |
Correct |
0 ms |
348 KB |
Output is correct |
85 |
Correct |
0 ms |
348 KB |
Output is correct |
86 |
Correct |
0 ms |
348 KB |
Output is correct |
87 |
Correct |
0 ms |
344 KB |
Output is correct |
88 |
Correct |
0 ms |
348 KB |
Output is correct |
89 |
Correct |
57 ms |
9956 KB |
Output is correct |
90 |
Correct |
21 ms |
5696 KB |
Output is correct |
91 |
Correct |
31 ms |
5640 KB |
Output is correct |
92 |
Correct |
13 ms |
4868 KB |
Output is correct |
93 |
Correct |
55 ms |
7924 KB |
Output is correct |
94 |
Correct |
18 ms |
5048 KB |
Output is correct |
95 |
Correct |
27 ms |
5556 KB |
Output is correct |
96 |
Correct |
31 ms |
10932 KB |
Output is correct |
97 |
Correct |
34 ms |
11176 KB |
Output is correct |
98 |
Correct |
29 ms |
6212 KB |
Output is correct |
99 |
Correct |
37 ms |
10940 KB |
Output is correct |
100 |
Correct |
2 ms |
348 KB |
Output is correct |
101 |
Correct |
1 ms |
348 KB |
Output is correct |
102 |
Correct |
2 ms |
348 KB |
Output is correct |
103 |
Correct |
2 ms |
348 KB |
Output is correct |
104 |
Correct |
2 ms |
348 KB |
Output is correct |
105 |
Correct |
2 ms |
604 KB |
Output is correct |
106 |
Correct |
3 ms |
604 KB |
Output is correct |
107 |
Correct |
3 ms |
604 KB |
Output is correct |
108 |
Correct |
15 ms |
2440 KB |
Output is correct |
109 |
Correct |
58 ms |
10156 KB |
Output is correct |
110 |
Correct |
101 ms |
11028 KB |
Output is correct |
111 |
Correct |
71 ms |
11184 KB |
Output is correct |
112 |
Correct |
66 ms |
10768 KB |
Output is correct |
113 |
Correct |
66 ms |
11040 KB |
Output is correct |
114 |
Correct |
182 ms |
12172 KB |
Output is correct |
115 |
Correct |
118 ms |
9116 KB |
Output is correct |
116 |
Correct |
29 ms |
4932 KB |
Output is correct |
117 |
Correct |
31 ms |
5128 KB |
Output is correct |
118 |
Correct |
36 ms |
5128 KB |
Output is correct |
119 |
Correct |
31 ms |
4560 KB |
Output is correct |
120 |
Correct |
163 ms |
9500 KB |
Output is correct |
121 |
Correct |
161 ms |
9516 KB |
Output is correct |
122 |
Correct |
181 ms |
9528 KB |
Output is correct |
123 |
Correct |
172 ms |
8860 KB |
Output is correct |
124 |
Correct |
168 ms |
8972 KB |
Output is correct |
125 |
Correct |
171 ms |
8868 KB |
Output is correct |
126 |
Correct |
189 ms |
8376 KB |
Output is correct |
127 |
Correct |
156 ms |
8332 KB |
Output is correct |
128 |
Correct |
141 ms |
8248 KB |
Output is correct |
129 |
Correct |
19 ms |
2460 KB |
Output is correct |
130 |
Correct |
78 ms |
11044 KB |
Output is correct |
131 |
Correct |
63 ms |
9824 KB |
Output is correct |
132 |
Correct |
90 ms |
11556 KB |
Output is correct |
133 |
Correct |
134 ms |
10972 KB |
Output is correct |
134 |
Correct |
152 ms |
10420 KB |
Output is correct |
135 |
Correct |
3 ms |
604 KB |
Output is correct |
136 |
Correct |
3 ms |
604 KB |
Output is correct |
137 |
Correct |
3 ms |
604 KB |
Output is correct |
138 |
Correct |
4 ms |
604 KB |
Output is correct |
139 |
Correct |
3 ms |
600 KB |
Output is correct |
140 |
Correct |
3 ms |
736 KB |
Output is correct |
141 |
Correct |
4 ms |
604 KB |
Output is correct |
142 |
Correct |
4 ms |
604 KB |
Output is correct |
143 |
Correct |
4 ms |
604 KB |
Output is correct |
144 |
Correct |
3 ms |
604 KB |
Output is correct |
145 |
Correct |
4 ms |
604 KB |
Output is correct |
146 |
Correct |
2 ms |
496 KB |
Output is correct |
147 |
Correct |
2 ms |
600 KB |
Output is correct |
148 |
Correct |
3 ms |
600 KB |
Output is correct |
149 |
Correct |
2 ms |
604 KB |
Output is correct |
150 |
Correct |
0 ms |
348 KB |
Output is correct |
151 |
Correct |
1 ms |
348 KB |
Output is correct |
152 |
Correct |
1 ms |
348 KB |
Output is correct |
153 |
Correct |
1 ms |
348 KB |
Output is correct |
154 |
Correct |
1 ms |
348 KB |
Output is correct |
155 |
Correct |
1 ms |
348 KB |
Output is correct |
156 |
Correct |
2 ms |
348 KB |
Output is correct |
157 |
Correct |
1 ms |
348 KB |
Output is correct |
158 |
Correct |
1 ms |
348 KB |
Output is correct |
159 |
Correct |
2 ms |
604 KB |
Output is correct |
160 |
Correct |
1 ms |
604 KB |
Output is correct |
161 |
Correct |
2 ms |
600 KB |
Output is correct |
162 |
Correct |
183 ms |
10052 KB |
Output is correct |
163 |
Correct |
9 ms |
1116 KB |
Output is correct |
164 |
Correct |
16 ms |
1748 KB |
Output is correct |
165 |
Correct |
28 ms |
3104 KB |
Output is correct |
166 |
Correct |
60 ms |
5136 KB |
Output is correct |
167 |
Correct |
100 ms |
8028 KB |
Output is correct |
168 |
Correct |
26 ms |
4932 KB |
Output is correct |
169 |
Correct |
33 ms |
4928 KB |
Output is correct |
170 |
Correct |
52 ms |
5040 KB |
Output is correct |
171 |
Correct |
34 ms |
4544 KB |
Output is correct |
172 |
Correct |
9 ms |
1372 KB |
Output is correct |
173 |
Correct |
11 ms |
1300 KB |
Output is correct |
174 |
Correct |
14 ms |
1360 KB |
Output is correct |
175 |
Correct |
11 ms |
1252 KB |
Output is correct |
176 |
Correct |
11 ms |
1372 KB |
Output is correct |
177 |
Correct |
20 ms |
1616 KB |
Output is correct |
178 |
Correct |
135 ms |
10236 KB |
Output is correct |
179 |
Correct |
152 ms |
10004 KB |
Output is correct |
180 |
Correct |
165 ms |
9464 KB |
Output is correct |
181 |
Correct |
152 ms |
9432 KB |
Output is correct |
182 |
Correct |
129 ms |
9392 KB |
Output is correct |
183 |
Correct |
139 ms |
9480 KB |
Output is correct |
184 |
Correct |
149 ms |
8788 KB |
Output is correct |
185 |
Correct |
152 ms |
8844 KB |
Output is correct |
186 |
Correct |
173 ms |
8884 KB |
Output is correct |
187 |
Correct |
123 ms |
8804 KB |
Output is correct |
188 |
Correct |
123 ms |
8332 KB |
Output is correct |
189 |
Correct |
111 ms |
8264 KB |
Output is correct |
190 |
Correct |
102 ms |
8368 KB |
Output is correct |
191 |
Correct |
104 ms |
8376 KB |
Output is correct |
192 |
Correct |
128 ms |
9552 KB |
Output is correct |
193 |
Correct |
165 ms |
9436 KB |
Output is correct |
194 |
Correct |
111 ms |
9432 KB |
Output is correct |
195 |
Correct |
112 ms |
9428 KB |
Output is correct |
196 |
Correct |
150 ms |
8800 KB |
Output is correct |
197 |
Correct |
111 ms |
8740 KB |
Output is correct |
198 |
Correct |
111 ms |
8904 KB |
Output is correct |
199 |
Correct |
120 ms |
8872 KB |
Output is correct |
200 |
Correct |
173 ms |
8332 KB |
Output is correct |
201 |
Correct |
107 ms |
8388 KB |
Output is correct |
202 |
Correct |
117 ms |
8364 KB |
Output is correct |
203 |
Correct |
120 ms |
8404 KB |
Output is correct |
204 |
Correct |
166 ms |
9480 KB |
Output is correct |
205 |
Correct |
125 ms |
9300 KB |
Output is correct |
206 |
Correct |
123 ms |
9420 KB |
Output is correct |
207 |
Correct |
168 ms |
9404 KB |
Output is correct |
208 |
Correct |
191 ms |
8800 KB |
Output is correct |
209 |
Correct |
144 ms |
8800 KB |
Output is correct |
210 |
Correct |
156 ms |
8796 KB |
Output is correct |
211 |
Correct |
144 ms |
8892 KB |
Output is correct |
212 |
Correct |
121 ms |
8220 KB |
Output is correct |
213 |
Correct |
141 ms |
8256 KB |
Output is correct |
214 |
Correct |
111 ms |
8332 KB |
Output is correct |
215 |
Correct |
155 ms |
8364 KB |
Output is correct |
216 |
Correct |
24 ms |
2504 KB |
Output is correct |
217 |
Correct |
73 ms |
11060 KB |
Output is correct |
218 |
Correct |
42 ms |
9756 KB |
Output is correct |
219 |
Correct |
80 ms |
11564 KB |
Output is correct |
220 |
Correct |
89 ms |
10840 KB |
Output is correct |
221 |
Correct |
126 ms |
10316 KB |
Output is correct |