QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#870720 | #8613. Cardinality | ucup-team5243# | ML | 317ms | 212472kb | C++23 | 16.2kb | 2025-01-25 17:30:09 | 2025-01-25 17:30:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifndef LOCAL_TEST
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif // LOCAL_TEST
using ll = long long;
using i128 = __int128_t;
using str = string;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vc = vector<char>; using vvc = vector<vc>; using vvvc = vector<vvc>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using vs = vector<string>; using vvs = vector<vector<string>>; using vvvs = vector<vector<vector<string>>>;
template<typename T> vector<vector<T>> vv(int h, int w, T val = T()) { return vector(h, vector<T>(w, val)); }
template<typename T> vector<vector<vector<T>>> vvv(int h1, int h2, int h3, T val = T()) { return vector(h1, vector(h2, vector<T>(h3, val))); }
template<typename T> vector<vector<vector<vector<T>>>> vvvv(int h1, int h2, int h3, int h4, T val = T()) { return vector(h1, vector(h2, vector(h3, vector<T>(h4, val)))); }
template <class T> using priority_queue_min = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.14159265358979323;
constexpr int INF = 100100111; constexpr ll INFL = 3300300300300300491LL;
float EPS = 1e-8; double EPSL = 1e-10;
struct Nyan { Nyan() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } } nyan;
#define all(a) (a).begin(), (a).end()
#define len(x) ((ll)(x).size())
#define sz(x) ((ll)(x).size())
#define rep1(n) for(ll dummy_iter = 0LL; dummy_iter < n; ++dummy_iter) // 0,1,...,n-1
#define rep2(i, n) for(ll i = 0LL, i##_counter = 0LL; i##_counter < ll(n); ++(i##_counter), (i) = i##_counter) // i=0,1,...,n-1
#define rep3(i, s, t) for(ll i = ll(s), i##_counter = ll(s); i##_counter < ll(t); ++(i##_counter), (i) = (i##_counter)) // i=s,s+1,...,t-1
#define rep4(i, s, t, step) for(ll i##_counter = step > 0 ? ll(s) : -ll(s), i##_end = step > 0 ? ll(t) : -ll(t), i##_step = abs(step), i = ll(s); i##_counter < i##_end; i##_counter += i##_step, i = step > 0 ? i##_counter : -i##_counter) // i=s,s+step,...,<t
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define repe(a, v) for(auto&& a : (v)) // iterate over all elements in v
#define repc(a, v) for(const auto& a : (v)) // iterate over all elements in v
#define smod(n, m) ((((n) % (m)) + (m)) % (m))
#define sdiv(n, m) (((n) - smod(n, m)) / (m))
#define uniq(a) {sort(all(a)); (a).erase(unique(all(a)), (a).end());}
int Yes(bool b=true) { cout << (b ? "Yes\n" : "No\n"); return 0; };
int YES(bool b=true) { cout << (b ? "YES\n" : "NO\n"); return 0; };
int No(bool b=true) {return Yes(!b);};
int NO(bool b=true) {return YES(!b);};
template<typename T, size_t N> T max(array<T, N>& a) { return *max_element(all(a)); };
template<typename T, size_t N> T min(array<T, N>& a) { return *min_element(all(a)); };
template<typename T> T max(vector<T>& a) { return *max_element(all(a)); };
template<typename T> T min(vector<T>& a) { return *min_element(all(a)); };
template<typename T> vector<T> vec_slice(const vector<T>& a, int l, int r) { vector<T> rev; rep(i, l, r) rev.push_back(a[i]); return rev; };
template<typename T> vector<T> vec_slice(const vector<T>&& a, int l, int r) { vector<T> rev; rep(i, l, r) rev.push_back(a[i]); return rev; };
template<typename T> T sum(vector<T>& a, T zero = T(0)) { T rev = zero; rep(i, sz(a)) rev += a[i]; return rev; };
template<typename T> T sum(vector<T>&& a, T zero = T(0)) { T rev = zero; rep(i, sz(a)) rev += a[i]; return rev; };
template <class T> inline vector<T>& operator--(vector<T>& v) { repe(x, v) --x; return v; }
template <class T> inline vector<T>& operator++(vector<T>& v) { repe(x, v) ++x; return v; }
ll powll(ll a, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1) res = (res * a);
if (n > 1) a = (a * a);
n >>= 1;
}
return res;
}
ll powm32(ll a, ll n, int mod) {
ll res = 1;
while (n > 0) {
if (n & 1) res = (res * a) % mod;
if (n > 1) a = (a * a) % mod;
n >>= 1;
}
return res % mod;
}
ll powm64(i128 a,i128 n,ll mod){
i128 res = 1;
while (n > 0) {
if (n & 1) res = (res * a) % mod;
if (n > 1) a = (a * a) % mod;
n >>= 1;
}
return res % mod;
}
ll sqrtll(ll x) {
assert(x >= 0);
ll rev = sqrt(x);
while(rev * rev > x) --rev;
while((rev+1) * (rev+1)<=x) ++rev;
return rev;
}
template <class T> inline bool chmax(T& M, const T& x) { if (M < x) { M = x; return true; } return false; }
template <class T> inline bool chmin(T& m, const T& x) { if (m > x) { m = x; return true; } return false; }
template <class T, class U> inline istream& operator>>(istream& is, pair<T, U>& p);
template <class T> inline istream& operator>>(istream& is, vector<T>& v);
template <class T, class U> inline ostream& operator<<(ostream& os, const pair<T, U>& p);
template <class T> inline ostream& operator<<(ostream& os, const vector<T>& v);
template <typename T, typename S> ostream &operator<<(ostream &os, const map<T, S> &mp);
template <typename T> ostream &operator<<(ostream &os, const set<T> &st);
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st);
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &st);
template <typename T> ostream &operator<<(ostream &os, deque<T> q);
template <class T, class Container, class Compare> ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> pq);
template <class T, class U> inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template <class T> inline istream& operator>>(istream& is, vector<T>& v) { repe(x, v) is >> x; return is; }
template <class T, class U> inline ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template <class T> inline ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { os << v.at(i); if (i != sz(v) - 1) os << " "; } return os; }
template <typename T, typename S> ostream &operator<<(ostream &os, const map<T, S> &mp) { for (auto &[key, val] : mp) { os << key << ":" << val << " "; } return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? " " : ""); itr++; } return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? " " : ""); itr++; } return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &st) { ll cnt = 0; for (auto &e : st) { os << e << (++cnt != (int)st.size() ? " " : ""); } return os; }
template <typename T> ostream &operator<<(ostream &os, deque<T> q) { while (q.size()) { os << q.front(); q.pop_front(); if (q.size()) os << " "; } return os; }
template <class T, class Container, class Compare> ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> pq) { while (pq.size()) { os << pq.top() << " "; pq.pop(); } return os; }
#define dout(x) cout << fixed << setprecision(10) << x << endl
#define read1(a) cin >> a;
#define read2(a, b) cin >> a >> b;
#define read3(a, b, c) cin >> a >> b >> c;
#define read4(a, b, c, d) cin >> a >> b >> c >> d;
#define read5(a, b, c, d, e) cin >> a >> b >> c >> d >> e;
#define read6(a, b, c, d, e, f) cin >> a >> b >> c >> d >> e >> f;
#define read7(a, b, c, d, e, f, g) cin >> a >> b >> c >> d >> e >> f >> g;
#define read8(a, b, c, d, e, f, g, h) cin >> a >> b >> c >> d >> e >> f >> g >> h;
#define overload_read(a, b, c, d, e, f, g, h, i, ...) i
#define read(...) overload_read(__VA_ARGS__,read8,read7,read6,read5,read4,read3,read2,read1)(__VA_ARGS__)
#ifdef LOCAL_TEST
#define inner_output1(a) cout << a << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << endl;
#define inner_output2(a, b) cout << a << " " << b << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " <<b << endl;
#define inner_output3(a, b, c) cout << a << " " << b << " " << c << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << endl;
#define inner_output4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << " " << d << endl;
#define inner_output5(a, b, c, d, e) cout << a << " " << b << " " << c << " " << d << " " << e << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << " " << d << " " << e << endl;
#define inner_output6(a, b, c, d, e, f) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;
#define inner_output7(a, b, c, d, e, f, g) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << endl;
#define inner_output8(a, b, c, d, e, f, g, h) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << endl;
#else
#define inner_output1(a) cout << a << endl;
#define inner_output2(a, b) cout << a << " " << b << endl;
#define inner_output3(a, b, c) cout << a << " " << b << " " << c << endl;
#define inner_output4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl;
#define inner_output5(a, b, c, d, e) cout << a << " " << b << " " << c << " " << d << " " << e << endl;
#define inner_output6(a, b, c, d, e, f) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;
#define inner_output7(a, b, c, d, e, f, g) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << endl;
#define inner_output8(a, b, c, d, e, f, g, h) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << endl;
#endif
#define overload_inner_output(a, b, c, d, e, f, g, h, i, ...) i
#define out(...) overload_inner_output(__VA_ARGS__,inner_output8,inner_output7,inner_output6,inner_output5,inner_output4,inner_output3,inner_output2,inner_output1)(__VA_ARGS__)
#define ii(...) ll __VA_ARGS__; read(__VA_ARGS__)
#define si(...) string __VA_ARGS__; read(__VA_ARGS__)
#define ci(...) char __VA_ARGS__; read(__VA_ARGS__)
#define di(...) double __VA_ARGS__; read(__VA_ARGS__)
#define li(name,size); vector<ll> name(size); read(name)
#define lli(name,H,W); vector name(H,vector<ll>(W));rep(i,H) cin >> name[i];
#ifdef LOCAL_TEST
#define inner_debug1(a) cerr << "[DEBUG#" << __LINE__ << "] " << #a << " = " << a << endl;
#define inner_debug2(a, b) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << endl;
#define inner_debug3(a, b, c) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << endl;
#define inner_debug4(a, b, c, d) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << endl;
#define inner_debug5(a, b, c, d, e) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << ", " << #e << " = " << e << endl;
#define inner_debug6(a, b, c, d, e, f) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << ", " << #e << " = " << e << ", " << #f << " = " << f << endl;
#define inner_debug7(a, b, c, d, e, f, g) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << ", " << #e << " = " << e << ", " << #f << " = " << f << ", " << #g << " = " << g << endl;
#define inner_debug8(a, b, c, d, e, f, g, h) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << ", " << #e << " = " << e << ", " << #f << " = " << f << ", " << #g << " = " << g << ", " << #h << " = " << h << endl;
#define overload_inner_debug(a, b, c, d, e, f, g, h, i, ...) i
#define debug(...) overload_inner_debug(__VA_ARGS__,inner_debug8,inner_debug7,inner_debug6,inner_debug5,inner_debug4,inner_debug3,inner_debug2,inner_debug1)(__VA_ARGS__)
#else
#define debug(...);
#endif // LOCAL_TEST
inline ll ctz(ll x) { return __builtin_ctzll(x);}
inline ll clz(ll x) { return __builtin_clzll(x);}
inline ll popcount(ll x) { return __builtin_popcountll(x);}
inline bool inrange(ll x, ll a, ll b) { return a <= x && x < b; }
template <typename T> inline ll findll(vector<T>& v, T x) { auto tmp = find(all(v), x);if(tmp == v.end()){return -1;}else{return distance(v.begin(),tmp); }}
inline ll findll(string& s, char x) { auto tmp = find(all(s), x);if(tmp == s.end()){return -1;}else{return distance(s.begin(),tmp); }}
inline ll ceildiv(ll x,ll y){return (x+y-1)/y;}
#define allit(a,pred) [&]{repc(it,a){if(!(pred)) return false;}return true;}()
#define anyit(a,pred) [&]{repc(it,a){if((pred)) return true;}return false;}()
#define mapit(a, pred) ([&]() { \
decltype(a)::value_type it; \
vector<decltype(pred)> result_mapit(a.size()); \
rep(idx,a.size()){\
decltype(a)::value_type& it = a[idx];\
result_mapit[idx] = pred;\
}\
return result_mapit; \
})()
#define filterit(a, pred) ([&]() { \
decltype(a) result_filterit; \
rep(idx,a.size()){\
decltype(a)::value_type& it = a[idx];\
if(pred){\
result_filterit.push_back(it);\
}\
}\
return result_filterit; \
})()
#define applyit(a, pred) { \
rep(idx,a.size()){\
decltype(a)::value_type& it = a[idx];\
a[idx] = pred;\
}\
}
#define countit(a, pred) ([&]() { \
ll result_countit = 0; \
rep(idx,a.size()){\
decltype(a)::value_type& it = a[idx];\
if(pred){\
result_countit++;\
}\
}\
return result_countit; \
})()
#define sortByIt(a,pred) {\
sort(all(a),[&](const decltype(a)::value_type& left_value, const decltype(a)::value_type& right_value){auto it = left_value;auto x_value = pred;it = right_value;auto y_value = pred;return x_value<y_value;});\
}
ll minIndex(vector<ll>& a) {
ll minIndex = 0;
rep(i, 1, sz(a)) {
if (a[i] < a[minIndex]) {
minIndex = i;
}
}
return minIndex;
}
ll maxIndex(vector<ll>& a) {
ll maxIndex = 0;
rep(i, 1, sz(a)) {
if (a[i] > a[maxIndex]) {
maxIndex = i;
}
}
return maxIndex;
}
template<typename T> vector<T> sorted(vector<T> X){
sort(all(X));
return X;
}
vector<string> split(const string& s,char c){
vector<string> res;
res.push_back("");
repc(a,s){
if(a==c){
res.push_back("");
}else{
res.back() += a;
}
}
return res;
}
int main(){
ii(N,Q);
vector<pll> P(N+Q+1);
vector<ll> cnt(N+Q+1,0);
vector<ll> memo(N+Q+1,-1);
vector<bitset<12500>> memoset(0);
auto get_set = [&](auto self,ll x) -> bitset<12500>{
if(x <= N){
bitset<12500> res;
res.set((x-1)/4,1);
return res;
}
if(memo[x] != -1){
return memoset[memo[x]];
}
cnt[x]++;
debug(x,P[x].first,P[x].second);
bitset<12500> res = self(self,P[x].first) | self(self,P[x].second);
if(cnt[x] == 3){
memoset.push_back(res);
memo[x] = sz(memoset)-1;
}
return res;
};
rep(i,Q){
cin >> P[N+i+1].first >> P[N+i+1].second;
auto st = get_set(get_set,N+i+1);
out(st.count()*2);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
4 5 1 2 2 3 5 6 6 7 4 7
output:
2 2 2 2 2
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
10 100 9 2 9 10 5 1 6 6 13 14 3 4 3 8 8 4 16 5 14 2 8 13 14 9 6 17 15 11 24 7 24 20 1 26 14 27 6 18 14 14 15 11 14 25 8 11 7 30 3 11 12 3 6 19 29 36 30 9 38 6 2 28 12 40 33 25 20 42 17 30 23 1 34 41 41 36 7 18 39 45 32 4 30 21 46 26 12 39 42 42 46 48 31 54 16 37 42 4 27 34 10 35 11 12 1 35 51 23 17 ...
output:
4 2 4 2 4 2 4 4 4 4 4 4 4 6 6 6 6 6 4 2 6 6 6 2 4 4 4 6 4 6 6 6 6 6 4 4 6 6 4 6 6 4 6 4 6 6 6 4 6 6 4 4 4 6 4 2 6 6 6 6 6 6 6 6 6 6 4 6 6 6 6 4 6 4 2 6 6 6 6 6 6 6 6 6 6 4 2 6 6 4 6 6 4 6 4 6 6 6 6 6
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
100 100 82 51 68 54 25 11 21 47 84 43 78 91 1 88 29 50 10 62 38 29 100 65 23 4 77 10 29 7 59 39 56 81 73 3 113 10 49 25 59 103 20 40 42 55 46 87 9 26 30 43 70 97 7 12 2 54 41 68 82 60 129 69 86 82 85 38 105 71 81 58 59 36 76 111 10 68 108 19 46 31 127 60 35 120 79 125 138 21 14 10 64 72 140 127 126 ...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 4 4 4 4 4 6 4 4 6 4 4 6 4 6 4 6 8 6 6 4 4 8 6 6 6 4 6 8 4 4 6 4 8 6 10 8 4 8 8 4 8 6 6 8 4 4 6 4 6 10 4 10 6 6 6 6 8 6 4 4 6 10 6 6 6 4 4 10 8 4 8 8 6 4 8
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
1000 1000 89 983 726 406 473 684 779 306 5 585 185 774 484 220 988 291 857 606 783 143 238 193 187 68 342 227 833 183 645 453 714 271 717 845 811 608 601 1013 101 716 563 790 500 449 962 863 255 787 236 837 560 412 788 681 487 992 311 884 389 251 199 927 942 1013 760 829 794 763 323 37 380 773 520 9...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 6 6 4 4 4 4 4 4 4 4 4 6 4 6 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 4 6 4 4 4 6 4 4 4 4 4 4 4 4 4 4 8 6 4 4 8 4 4 4 4 6 4 4 4 4 4 6 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 6 6 4 4 6 ...
result:
ok
Test #5:
score: 0
Accepted
time: 9ms
memory: 18300kb
input:
1000 10000 609 422 750 225 479 328 513 581 935 302 164 982 913 807 716 785 888 102 867 698 397 957 743 229 35 252 222 697 614 421 442 266 748 44 698 740 556 746 748 637 259 372 752 867 503 605 483 380 586 608 977 584 603 335 347 202 514 622 343 167 700 845 370 673 597 499 314 38 647 976 784 644 721 ...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 8 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 6 6 4 4 4 6 4 6 4 4 4 4 4 4 4 4 4 6 4 4 6 6 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 4 6 4 4 6 4 4 4 4 4 4 4 4 4 4 4 4 8 4 ...
result:
ok
Test #6:
score: 0
Accepted
time: 152ms
memory: 108092kb
input:
1000 100000 359 877 601 2 857 749 72 386 503 918 74 209 504 14 653 714 168 192 993 870 342 822 540 854 495 452 996 651 1005 932 898 279 105 83 778 924 517 326 326 16 747 863 73 501 190 386 211 416 330 72 857 269 543 485 344 637 111 611 449 942 426 739 585 459 100 269 1025 249 763 945 834 432 492 148...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 6 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 6 4 4 6 4 6 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 6 4 4 4 6 6 4 4 4 4 4 4 6 6 4 4 4 4 8 4 4 4 4 6 4 4 6 4 6 4 4 4 4 4 4 4 4 4 4 4 4 6 10 4 4 4 6 4 4 4 8 4 4...
result:
ok
Test #7:
score: 0
Accepted
time: 317ms
memory: 212472kb
input:
1000 200000 769 45 350 115 462 826 361 748 422 502 757 529 131 165 525 252 5 610 58 557 894 966 867 661 699 337 508 118 248 715 307 307 814 382 957 825 302 694 22 761 146 621 149 929 553 337 428 844 429 371 355 740 889 726 1017 938 31 269 906 259 173 45 852 442 41 87 179 284 866 1033 115 130 757 192...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 4 6 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 4 4 10 6 8 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 8 6 6 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 6 4 4 4 4 4 6 4 6 4 4 4 4 4 4 4 6 4 4 4 4 4 4 4 4 6 4 6 8 4 4 4 4 4 4 4 6...
result:
ok
Test #8:
score: -100
Memory Limit Exceeded
input:
1000 500000 24 935 982 976 490 112 293 703 499 131 922 786 572 620 322 364 508 616 333 817 664 297 581 82 257 726 95 310 119 28 208 523 86 518 866 919 777 618 314 979 640 663 377 898 713 187 64 78 725 243 883 113 868 514 546 816 945 529 749 724 300 243 282 41 625 398 376 572 63 420 91 995 715 757 12...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 4 6 4 4 4 4 4 4 4 4 4 4 8 4 4 4 4 4 4 4 4 4 4 4 4 4 8 6 4 4 4 4 6 8 4 6 4 4 4 4 4 6 4 4 4 6 4 4 4 4 4 4 4 4 4 4 4 4 6 4 4 4 4 4 6 4 4 4 4 2 4 4 6 4 4 4 4 4 6 4 6 4 10 4 4 6 4 6 4 4 4 6 4 4 6 4 4 4 4 4 4 4...