QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#288933 | #7860. Graph of Maximum Degree 3 | ucup-team112# | AC ✓ | 465ms | 66600kb | C++20 | 18.2kb | 2023-12-23 14:17:39 | 2023-12-23 14:17:39 |
Judging History
answer
//#define _GLIBCXX_DEBUG
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug_print.hpp>
#define OUT(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define OUT(...) (static_cast<void>(0))
#endif
#define endl '\n'
#define lfs cout<<fixed<<setprecision(15)
#define ALL(a) (a).begin(),(a).end()
#define ALLR(a) (a).rbegin(),(a).rend()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using QP = priority_queue<T,vector<T>,greater<T>>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T1,typename T2,typename T3>void anss(T1 x,T2 y,T3 z){ans(x!=y,x,z);};
template<typename T>void debug(const T &v,ll h,ll w,string sv=" "){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout<<sv<<v[i][j];cout<<endl;}};
template<typename T>void debug(const T &v,ll n,string sv=" "){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout<<sv<<v[i];cout<<endl;};
template<typename T>void debug(const vector<T>&v){debug(v,v.size());}
template<typename T>void debug(const vector<vector<T>>&v){for(auto &vv:v)debug(vv,vv.size());}
template<typename T>void debug(stack<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(queue<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(deque<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop_front();}cout<<endl;}
template<typename T>void debug(PQ<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(QP<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(const set<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
template<typename T>void debug(const multiset<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
template<typename T,size_t size>void debug(const array<T, size> &a){for(auto z:a)cout<<z<<" ";cout<<endl;}
template<typename T,typename V>void debug(const map<T,V>&v){for(auto z:v)cout<<"["<<z.first<<"]="<<z.second<<",";cout<<endl;}
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << "(" << p.first << "," << p.second << ")";}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){os<<"[";for(auto &z:v)os << z << ",";os<<"]"; return os;}
template<typename T>void rearrange(vector<int>&ord, vector<T>&v){
auto tmp = v;
for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
}
template<typename Head, typename... Tail>void rearrange(vector<int>&ord,Head&& head, Tail&&... tail){
rearrange(ord, head);
rearrange(ord, tail...);
}
template<typename T> vector<int> ascend(const vector<T>&v){
vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],i)<make_pair(v[j],j);});
return ord;
}
template<typename T> vector<int> descend(const vector<T>&v){
vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],-i)>make_pair(v[j],-j);});
return ord;
}
template<typename T> vector<T> inv_perm(const vector<T>&ord){
vector<T>inv(ord.size());
for(int i=0;i<ord.size();i++)inv[ord[i]] = i;
return inv;
}
ll FLOOR(ll n,ll div){assert(div>0);return n>=0?n/div:(n-div+1)/div;}
ll CEIL(ll n,ll div){assert(div>0);return n>=0?(n+div-1)/div:n/div;}
ll digitsum(ll n){ll ret=0;while(n){ret+=n%10;n/=10;}return ret;}
ll modulo(ll n,ll d){return (n%d+d)%d;};
template<typename T>T min(const vector<T>&v){return *min_element(v.begin(),v.end());}
template<typename T>T max(const vector<T>&v){return *max_element(v.begin(),v.end());}
template<typename T>T acc(const vector<T>&v){return accumulate(v.begin(),v.end(),T(0));};
template<typename T>T reverse(const T &v){return T(v.rbegin(),v.rend());};
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int popcount(ll x){return __builtin_popcountll(x);};
int poplow(ll x){return __builtin_ctzll(x);};
int pophigh(ll x){return 63 - __builtin_clzll(x);};
template<typename T>T poll(queue<T> &q){auto ret=q.front();q.pop();return ret;};
template<typename T>T poll(priority_queue<T> &q){auto ret=q.top();q.pop();return ret;};
template<typename T>T poll(QP<T> &q){auto ret=q.top();q.pop();return ret;};
template<typename T>T poll(stack<T> &s){auto ret=s.top();s.pop();return ret;};
ll MULT(ll x,ll y){if(LLONG_MAX/x<=y)return LLONG_MAX;return x*y;}
ll POW2(ll x, ll k){ll ret=1,mul=x;while(k){if(mul==LLONG_MAX)return LLONG_MAX;if(k&1)ret=MULT(ret,mul);mul=MULT(mul,mul);k>>=1;}return ret;}
ll POW(ll x, ll k){ll ret=1;for(int i=0;i<k;i++){if(LLONG_MAX/x<=ret)return LLONG_MAX;ret*=x;}return ret;}
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
if (s) {
__uint128_t tmp = value < 0 ? -value : value;
char buffer[128];
char *d = std::end(buffer);
do {
--d;
*d = "0123456789"[tmp % 10];
tmp /= 10;
} while (tmp != 0);
if (value < 0) {
--d;
*d = '-';
}
int len = std::end(buffer) - d;
if (dest.rdbuf()->sputn(d, len) != len) {
dest.setstate(std::ios_base::badbit);
}
}
return dest;
}
namespace converter{
int dict[500];
const string lower="abcdefghijklmnopqrstuvwxyz";
const string upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string digit="0123456789";
const string digit1="123456789";
void regi_str(const string &t){
for(int i=0;i<t.size();i++){
dict[t[i]]=i;
}
}
void regi_int(const string &t){
for(int i=0;i<t.size();i++){
dict[i]=t[i];
}
}
vector<int>to_int(const string &s,const string &t){
regi_str(t);
vector<int>ret(s.size());
for(int i=0;i<s.size();i++){
ret[i]=dict[s[i]];
}
return ret;
}
vector<int>to_int(const string &s){
auto t=s;
sort(t.begin(),t.end());
t.erase(unique(t.begin(),t.end()),t.end());
return to_int(s,t);
}
vector<vector<int>>to_int(const vector<string>&s,const string &t){
regi_str(t);
vector<vector<int>>ret(s.size(),vector<int>(s[0].size()));
for(int i=0;i<s.size();i++){
for(int j=0;j<s[0].size();j++){
ret[i][j]=dict[s[i][j]];
}
}
return ret;
}
vector<vector<int>>to_int(const vector<string>&s){
string t;
for(int i=0;i<s.size();i++){
t+=s[i];
}
sort(t.begin(),t.end());t.erase(unique(t.begin(),t.end()),t.end());
return to_int(s,t);
}
string to_str(const vector<int>&s,const string &t){
regi_int(t);
string ret;
for(auto z:s)ret+=dict[z];
return ret;
}
vector<string> to_str(const vector<vector<int>>&s,const string &t){
regi_int(t);
vector<string>ret(s.size());
for(int i=0;i<s.size();i++){
for(auto z:s[i])ret[i]+=dict[z];
}
return ret;
}
}
template< typename T = int >
struct edge {
int to;
T cost;
int id;
edge():to(-1),id(-1){};
edge(int to, T cost = 1, int id = -1):to(to), cost(cost), id(id){}
operator int() const { return to; }
};
template<typename T>
using Graph = vector<vector<edge<T>>>;
template<typename T>
Graph<T>revgraph(const Graph<T> &g){
Graph<T>ret(g.size());
for(int i=0;i<g.size();i++){
for(auto e:g[i]){
int to = e.to;
e.to = i;
ret[to].push_back(e);
}
}
return ret;
}
template<typename T>
Graph<T> readGraph(int n,int m,int indexed=1,bool directed=false,bool weighted=false){
Graph<T> ret(n);
for(int es = 0; es < m; es++){
int u,v;
T w=1;
cin>>u>>v;u-=indexed,v-=indexed;
if(weighted)cin>>w;
ret[u].emplace_back(v,w,es);
if(!directed)ret[v].emplace_back(u,w,es);
}
return ret;
}
template<typename T>
Graph<T> readParent(int n,int indexed=1,bool directed=true){
Graph<T>ret(n);
for(int i=1;i<n;i++){
int p;cin>>p;
p-=indexed;
ret[p].emplace_back(i);
if(!directed)ret[i].emplace_back(p);
}
return ret;
}
struct UnionFind {
vector<ll> data;
ll num;
UnionFind(ll size) : data(size, -1) ,num(size){ }
bool unite(int x, int y) {
x = root(x); y = root(y);
if (x != y) {
if (data[y] < data[x]) swap(x, y);
data[x] += data[y]; data[y] = x;
num--;
}
return x != y;
}
bool find(int x, int y) {
return root(x) == root(y);
}
int root(int x) {
return data[x] < 0 ? x : data[x] = root(data[x]);
}
ll size(int x) {
return -data[root(x)];
}
vector<vector<int>>groups(){
vector<vector<int>>ret(data.size());
for(int i=0;i<data.size();i++){
ret[root(i)].push_back(i);
}
return ret;
}
void print(){
auto tmp=groups();
for(int i=0;i<data.size();i++){
if(!tmp[i].empty()){
for(auto z:tmp[i])cout<<z<<",";
cout<<endl;
}
}
}
};
struct RandomNumberGenerator {
mt19937_64 mt;
RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}
RandomNumberGenerator(int x) : mt(x){
cout<<"-----debug-----"<<endl;
}
ll operator()(ll a, ll b) { // [a, b)
uniform_int_distribution< ll > dist(a, b - 1);
return dist(mt);
}
ll operator()(ll b) { // [0, b)
return (*this)(0, b);
}
};
struct RollbackUnionFind {
vector<int> data;
stack<pair<int, int> > history;
int inner_snap;
RollbackUnionFind(int sz) : inner_snap(0) { data.assign(sz, -1); }
bool unite(int x, int y) {
x = find(x), y = find(y);
history.emplace(x, data[x]);
history.emplace(y, data[y]);
if (x == y) return false;
if (data[x] > data[y]) swap(x, y);
data[x] += data[y];
data[y] = x;
return true;
}
int find(int k) {
if (data[k] < 0) return k;
return find(data[k]);
}
int same(int x, int y) { return find(x) == find(y); }
int size(int k) { return (-data[find(k)]); }
void undo() {
data[history.top().first] = history.top().second;
history.pop();
data[history.top().first] = history.top().second;
history.pop();
}
void snapshot() { inner_snap = int(history.size() >> 1); }
int get_state() { return int(history.size() >> 1); }
void rollback(int state = -1) {
if (state == -1) state = inner_snap;
state <<= 1;
assert(state <= (int)history.size());
while (state < (int)history.size()) undo();
}
};
/**
* @brief RollbackつきUnion Find
* @docs docs/data-structure/rollback-union-find.md
*/
RandomNumberGenerator rng;
template<class Key, class Value, class Hash>
struct hash_map {
using size_type = std::size_t;
using key_type = Key;
using value_type = Value;
using pair_type = std::pair<key_type, value_type>;
enum class State: std::uint8_t {
INACTIVE,
ACTIVE,
FILLED
};
Hash hashf;
std::vector<State> st;
std::vector<pair_type> bck;
size_type mask;
size_type prode;
size_type sz;
size_type min_elem;
hash_map():
mask(0), prode(-1), sz(0), min_elem(0) {
}
size_type find_empty(const key_type& key) {
size_type h = hashf(key);
for(size_type delta = 0;;delta++) {
size_type i = (h + delta) & mask;
if(st[i] != State::FILLED) {
if(prode < delta) prode = delta;
return i;
}
}
}
size_type find_filled(const key_type& key) {
if(sz == 0) return size_type(-1);
size_type h = hashf(key);
for(size_type delta = 0; delta <= prode; delta++) {
size_type i = (h + delta) & mask;
if(st[i] == State::FILLED) {
if(bck[i].first == key) {
return i;
}
}
else if(st[i] == State::INACTIVE) {
return size_type(-1);
}
}
return size_type(-1);
}
size_type find_or_allocate(const key_type& key) {
size_type h = hashf(key);
size_type hole = size_type(-1);
size_type delta = 0;
for(; delta <= prode; delta++) {
size_type i = (h + delta) & mask;
if(st[i] == State::FILLED) {
if(bck[i].first == key) return i;
}
else if(st[i] == State::INACTIVE) return i;
else {
if(hole == size_type(-1)) {
hole = i;
}
}
}
if(hole != size_type(-1)) return hole;
for(; ; delta++) {
size_type i = (h + delta) & mask;
if(st[i] != State::FILLED) {
prode = delta;
return i;
}
}
}
void reserve(int next_cnt) {
size_type required_cnt = next_cnt + (next_cnt >> 1) + 1;
if(required_cnt > bck.size()) {
next_cnt = 4;
while(next_cnt < required_cnt) next_cnt <<= 1;
}
else if(next_cnt <= bck.size() / 4) {
next_cnt = std::max(4, (int)bck.size() / 2);
}
else {
return;
}
std::vector<State> old_st(next_cnt, State::INACTIVE);
std::vector<pair_type> old_bck(next_cnt);
std::swap(old_st, st);
std::swap(old_bck, bck);
mask = next_cnt - 1;
sz = 0;
prode = 0;
min_elem = next_cnt - 1;
for(size_type pos = 0; pos < old_bck.size(); pos++) {
if(old_st[pos] == State::FILLED) {
size_type i = find_empty(old_bck[pos].first);
st[i] = State::FILLED;
bck[i] = std::move(old_bck[pos]);
min_elem = std::min(min_elem, i);
sz += 1;
}
}
}
void insert(const key_type& key, const value_type& val) {
reserve(sz + 1);
size_type i = find_or_allocate(key);
if(st[i] != State::FILLED) {
st[i] = State::FILLED;
bck[i] = pair_type(key, val);
min_elem = std::min(min_elem, i);
sz++;
}
else {
bck[i] = pair_type(key, val);
}
}
bool erase(const key_type& key) {
size_type i = find_filled(key);
if(i == size_type(-1)) {
return false;
}
else {
st[i] = State::ACTIVE;
bck[i].~pair_type();
sz--;
return true;
}
}
pair_type* get(const key_type& key) {
size_type i = find_filled(key);
if(i == size_type(-1)) {
return nullptr;
}
else {
return &bck[i];
}
}
pair_type* get_or_insert(const key_type& key, const value_type val) {
reserve(sz + 1);
size_type i = find_or_allocate(key);
if(st[i] != State::FILLED) {
st[i] = State::FILLED;
bck[i] = pair_type(key, val);
min_elem = std::min(min_elem, i);
sz++;
}
return &bck[i];
}
pair_type get_and_erase(const key_type& key) {
size_type i = find_filled(key);
st[i] = State::ACTIVE;
pair_type p = std::move(bck[i]);
sz--;
return p;
}
template<class Func>
void search_all(Func func) {
for(size_type i = min_elem; i < bck.size(); i++) {
if(st[i] == State::FILLED) {
min_elem = i;
size_type res = func(bck[i]);
if(res & 0b10) {
st[i] = State::ACTIVE;
bck[i].~pair_type();
sz--;
}
if(res & 0b01) {
return;
}
}
}
}
size_type size() const { return sz; }
};
struct Hashu32 {
std::uint32_t operator()(std::uint32_t key) {
int c2=0x27d4eb2d; // a prime or an odd constant
key = (key ^ 61) ^ (key >> 16);
key = key + (key << 3);
key = key ^ (key >> 4);
key = key * c2;
key = key ^ (key >> 15);
return key;
}
};
struct Hashu64 {
std::size_t operator()(std::uint64_t key) {
key = (~key) + (key << 18); // key = (key << 18) - key - 1;
key = key ^ (key >> 31);
key = key * 21; // key = (key + (key << 2)) + (key << 4);
key = key ^ (key >> 11);
key = key + (key << 6);
key = key ^ (key >> 22);
return (int) key;
}
};
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
ll res=0,buf=0;
bool judge = true;
int n,m;cin>>n>>m;
Graph<int>g(n);
ll ret=0;
vector<ll>hash(n);
rep(i,0,n)hash[i]=rng(2LL,1LL<<62);
hash_map<ll,int,Hashu64>st;
rep(i,0,m){
int u,v,c;cin>>u>>v>>c;u--;v--;
g[u].EB(v,1,c);
g[v].EB(u,1,c);
}
RollbackUnionFind uf(n);
uf.snapshot();
rep(i,0,n){
vector<int>ver;
auto dfs=[&](auto &&f,int v)->void {
ver.PB(v);
ll h=0;
for(auto z:ver)h^=hash[z];
if(st.get(h)==nullptr){
st.insert(h,1);
bool comp=true;
rep(c,0,2){
for(auto z:ver){
for(auto e:g[z]){
if(e.id==c&&count(ALL(ver),e.to)){
uf.unite(z,e.to);
}
}
}
for(auto z:ver){
if(!uf.same(z,ver[0]))comp=false;
}
uf.rollback();
}
//OUT(ver,comp);
if(comp)ret++;
}
if(ver.size()<4){
for(auto to:g[v]){
if(count(ALL(ver),to))continue;
f(f,to);
}
}
ver.pop_back();
};
dfs(dfs,i);
}
cout<<ret%MOD9%MOD9%MOD9%MOD9<<endl;
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3836kb
input:
3 4 1 2 0 1 3 1 2 3 0 2 3 1
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
4 6 1 2 0 2 3 0 3 4 0 1 4 1 2 4 1 1 3 1
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
20 28 9 6 1 9 6 0 3 8 0 8 4 0 3 8 1 3 4 1 2 13 0 13 1 0 19 1 0 2 1 1 2 19 1 13 19 1 14 15 1 14 15 0 7 12 0 12 17 0 20 17 0 7 17 1 7 20 1 12 20 1 16 18 0 18 10 0 5 10 0 16 10 1 16 5 1 18 5 1 4 6 0 9 11 0
output:
27
result:
ok 1 number(s): "27"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
100 150 93 23 0 23 81 0 76 81 0 93 81 1 93 76 1 23 76 1 100 65 0 65 56 0 19 56 0 100 56 1 100 19 1 65 19 1 2 98 0 2 98 1 26 63 0 63 90 0 26 63 1 26 90 1 6 11 0 11 67 0 6 11 1 6 67 1 37 89 0 89 64 0 25 64 0 37 64 1 37 25 1 89 25 1 84 10 0 10 29 0 75 29 0 84 29 1 84 75 1 10 75 1 7 70 1 7 70 0 28 92 0 ...
output:
141
result:
ok 1 number(s): "141"
Test #5:
score: 0
Accepted
time: 98ms
memory: 25216kb
input:
100000 133680 36843 86625 0 86625 63051 0 35524 63051 0 36843 63051 1 36843 35524 1 86625 35524 1 55797 82715 0 55797 82715 1 70147 35104 0 35104 91732 0 70147 35104 1 70147 91732 1 94917 70395 0 70395 68250 0 24100 68250 0 94917 68250 1 94917 24100 1 70395 24100 1 83033 18450 1 83033 18450 0 34462 ...
output:
144604
result:
ok 1 number(s): "144604"
Test #6:
score: 0
Accepted
time: 100ms
memory: 25148kb
input:
100000 133388 86620 74346 0 74346 19047 0 54911 19047 0 86620 19047 1 86620 54911 1 74346 54911 1 23715 93094 0 93094 91208 0 63189 91208 0 23715 91208 1 23715 63189 1 93094 63189 1 99337 41426 1 99337 41426 0 83742 45546 0 45546 73862 0 83742 45546 1 83742 73862 1 85256 2812 0 2812 59368 0 85918 59...
output:
144348
result:
ok 1 number(s): "144348"
Test #7:
score: 0
Accepted
time: 152ms
memory: 39824kb
input:
100000 150000 86541 24385 0 24385 75745 0 52353 75745 0 86541 75745 1 86541 52353 1 24385 52353 1 89075 78015 0 89075 78015 1 52519 74846 0 74846 12045 0 73265 12045 0 52519 12045 1 52519 73265 1 74846 73265 1 17884 63159 0 63159 47308 0 56073 47308 0 17884 47308 1 17884 56073 1 63159 56073 1 72134 ...
output:
144639
result:
ok 1 number(s): "144639"
Test #8:
score: 0
Accepted
time: 152ms
memory: 39904kb
input:
100000 150000 91951 68612 1 91951 68612 0 18361 92673 0 92673 52678 0 86520 52678 0 18361 52678 1 18361 86520 1 92673 86520 1 58779 2421 0 58779 2421 1 66622 6461 0 6461 96943 0 66622 6461 1 66622 96943 1 27201 480 1 27201 480 0 19082 3895 0 3895 17796 0 3117 17796 0 19082 17796 1 19082 3117 1 3895 ...
output:
144471
result:
ok 1 number(s): "144471"
Test #9:
score: 0
Accepted
time: 147ms
memory: 39832kb
input:
100000 150000 43756 3552 0 3552 90269 0 43756 3552 1 43756 90269 1 11104 36935 1 11104 36935 0 11648 5480 0 5480 45320 0 11648 5480 1 11648 45320 1 19216 85746 0 19216 85746 1 68825 11173 0 11173 43155 0 68825 11173 1 68825 43155 1 27349 75259 0 27349 75259 1 1704 24478 0 24478 5980 0 1704 24478 1 1...
output:
144217
result:
ok 1 number(s): "144217"
Test #10:
score: 0
Accepted
time: 148ms
memory: 39840kb
input:
99999 149998 51151 43399 0 51151 43399 1 45978 28343 0 28343 9008 0 85724 9008 0 45978 9008 1 45978 85724 1 28343 85724 1 79446 12915 0 12915 65925 0 28869 65925 0 79446 65925 1 79446 28869 1 12915 28869 1 82642 95556 0 95556 68817 0 68334 68817 0 82642 68817 1 82642 68334 1 95556 68334 1 61212 7638...
output:
144219
result:
ok 1 number(s): "144219"
Test #11:
score: 0
Accepted
time: 140ms
memory: 39844kb
input:
100000 149999 26736 28785 0 28785 37945 0 26736 28785 1 26736 37945 1 1240 74368 0 74368 45022 0 1240 74368 1 1240 45022 1 40673 1276 0 1276 56395 0 40673 1276 1 40673 56395 1 35181 63341 0 63341 35131 0 60120 35131 0 35181 35131 1 35181 60120 1 63341 60120 1 99363 36973 0 99363 36973 1 85717 77683 ...
output:
144380
result:
ok 1 number(s): "144380"
Test #12:
score: 0
Accepted
time: 156ms
memory: 39912kb
input:
100000 150000 63695 11044 0 11044 34978 0 56531 34978 0 63695 34978 1 63695 56531 1 11044 56531 1 72139 3715 0 3715 21024 0 96696 21024 0 72139 21024 1 72139 96696 1 3715 96696 1 54670 49014 0 54670 49014 1 7670 61055 0 61055 38409 0 7670 61055 1 7670 38409 1 83399 50676 0 50676 98893 0 60069 98893 ...
output:
144559
result:
ok 1 number(s): "144559"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
1 0
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 4ms
memory: 13428kb
input:
100000 0
output:
100000
result:
ok 1 number(s): "100000"
Test #15:
score: 0
Accepted
time: 136ms
memory: 39588kb
input:
100000 150000 95066 31960 0 31960 89758 0 10935 89758 0 95066 89758 1 95066 10935 1 31960 10935 1 48016 97823 0 97823 10871 0 23454 10871 0 48016 10871 1 48016 23454 1 97823 23454 1 73749 35525 0 35525 54232 0 42182 54232 0 73749 54232 1 73749 42182 1 35525 42182 1 75405 71341 0 71341 70032 0 3284 7...
output:
125000
result:
ok 1 number(s): "125000"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
4 6 1 2 0 1 2 1 1 3 0 2 4 1 3 4 0 3 4 1
output:
7
result:
ok 1 number(s): "7"
Test #17:
score: 0
Accepted
time: 171ms
memory: 38280kb
input:
99998 115940 40840 40839 0 28249 28248 0 24785 24783 0 36536 36534 1 71904 71901 1 62023 62021 0 34737 34740 1 18430 18434 0 27506 27505 1 4665 4664 1 36578 36577 1 99311 99314 1 43484 43482 0 26457 26459 1 99698 99695 0 10170 10172 1 98176 98179 1 47786 47785 1 56529 56531 1 86896 86895 1 78204 782...
output:
104913
result:
ok 1 number(s): "104913"
Test #18:
score: 0
Accepted
time: 215ms
memory: 38828kb
input:
99996 126880 57665 57662 0 73031 73028 0 78744 78741 1 36913 36914 0 88139 88138 1 89276 89278 0 66433 66436 1 91069 91070 0 63929 63930 0 89625 89627 0 56400 56399 1 69226 69223 1 88433 88432 1 43807 43810 0 37146 37145 0 43789 43792 1 68123 68124 1 17957 17954 1 82804 82805 0 59808 59804 1 73840 7...
output:
103597
result:
ok 1 number(s): "103597"
Test #19:
score: 0
Accepted
time: 220ms
memory: 38944kb
input:
99996 128661 40089 40092 1 43861 43862 1 75629 75628 0 19597 19598 0 15151 15154 0 95642 95641 0 80320 80317 1 57255 57254 0 35316 35314 0 44675 44676 1 38847 38850 0 50886 50883 1 7617 7615 0 52310 52311 0 71474 71478 1 60036 60035 1 12009 12012 1 72347 72348 1 80343 80345 0 58804 58806 1 11386 113...
output:
103531
result:
ok 1 number(s): "103531"
Test #20:
score: 0
Accepted
time: 161ms
memory: 37660kb
input:
85086 109171 68997 68998 1 24077 24074 0 81830 81829 0 6102 6100 0 16851 16850 0 44103 44101 0 35639 35637 0 46162 46161 1 70373 70372 1 2625 2624 0 50990 50989 0 52220 52219 1 3452 3453 0 21915 21916 0 19561 19564 1 2616 2615 1 59039 59040 1 72589 72590 1 40147 40148 0 83359 83360 1 4274 4275 1 736...
output:
96534
result:
ok 1 number(s): "96534"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
6 9 1 2 0 1 2 1 1 3 0 2 3 1 3 4 0 4 5 0 4 6 1 5 6 0 5 6 1
output:
10
result:
ok 1 number(s): "10"
Test #22:
score: 0
Accepted
time: 195ms
memory: 38340kb
input:
99998 115940 91307 35051 0 41850 19274 0 35587 78894 0 26695 91651 1 79179 482 1 26680 7283 0 51999 18100 1 97541 51977 0 31565 24059 1 48770 33590 1 79885 37272 1 16578 79254 1 23825 66223 0 51722 3968 1 30481 33229 0 86577 14556 1 63261 87530 1 17567 19857 1 48438 12110 1 68610 47458 1 88373 92315...
output:
104913
result:
ok 1 number(s): "104913"
Test #23:
score: 0
Accepted
time: 237ms
memory: 38924kb
input:
99996 126880 31926 32431 0 89751 77638 0 81312 90949 1 9164 78061 0 79960 37357 1 15044 53165 0 46804 58840 1 96661 32396 0 93436 39774 0 81650 97489 0 28285 25380 1 51642 75847 1 38686 99309 1 65477 46389 0 17012 64436 0 39535 20467 1 55466 34797 1 56580 52438 1 88447 46598 0 94878 81598 1 36359 71...
output:
103597
result:
ok 1 number(s): "103597"
Test #24:
score: 0
Accepted
time: 255ms
memory: 38936kb
input:
99996 128661 68631 18634 1 39185 98747 1 93688 3993 0 63831 49896 0 88466 11249 0 76247 13150 0 44166 89827 1 14706 98796 0 55609 32463 0 96040 11481 1 15800 28436 0 35644 61568 1 90823 7941 0 16497 32517 0 70520 2507 1 36824 37963 1 43899 12185 1 16439 35062 1 22697 5663 0 22986 20940 1 93694 62377...
output:
103531
result:
ok 1 number(s): "103531"
Test #25:
score: 0
Accepted
time: 186ms
memory: 37652kb
input:
85086 109171 54967 52668 1 64243 48915 0 78737 27043 0 69272 84477 0 11191 72192 0 56490 36228 0 52083 25417 0 58946 51014 1 57855 26735 1 83625 46445 0 72878 43133 0 77230 69968 1 7791 38318 0 14928 27213 0 5215 50302 1 75864 25928 1 11582 54867 1 53793 83950 1 70191 16278 0 69499 3665 1 45931 3663...
output:
96534
result:
ok 1 number(s): "96534"
Test #26:
score: 0
Accepted
time: 187ms
memory: 39968kb
input:
100000 150000 99933 55358 0 90416 2554 0 64997 12630 0 43499 35304 0 43164 38359 0 82333 47941 0 15092 76350 1 6401 82373 0 90467 57736 1 72290 58218 0 64844 79192 0 71055 40232 1 54743 65698 0 19204 38062 1 1490 24882 0 18848 1970 1 18829 25405 0 93396 54676 1 5241 60149 0 26699 39910 1 70898 82827...
output:
150000
result:
ok 1 number(s): "150000"
Test #27:
score: 0
Accepted
time: 168ms
memory: 38884kb
input:
100000 130000 15237 21286 1 60817 70086 1 62915 43855 1 23616 97040 1 54175 84281 1 22498 80217 1 58904 98534 0 88649 79847 0 46299 28927 1 90160 25868 1 59368 62900 1 93860 42461 1 2630 7547 1 54787 84637 1 6577 95373 1 62108 8000 1 14358 53523 1 85474 77621 1 68271 30113 1 26333 71197 1 78110 6040...
output:
130000
result:
ok 1 number(s): "130000"
Test #28:
score: 0
Accepted
time: 187ms
memory: 36376kb
input:
65534 98300 42421 54323 0 45888 19783 0 11682 46414 0 41620 27016 0 62650 43400 1 24787 17246 0 38437 37760 0 51438 27810 0 5194 36179 0 42153 44739 0 38012 47581 0 64561 26437 0 30761 19033 0 29631 18563 0 10689 6913 0 9438 48319 0 18569 39847 0 21454 526 0 59916 36345 0 2577 7295 0 22843 14281 0 4...
output:
81918
result:
ok 1 number(s): "81918"
Test #29:
score: 0
Accepted
time: 190ms
memory: 36540kb
input:
65534 98300 44683 25158 1 35394 27103 0 11618 63123 1 26627 62829 1 63124 18531 1 38195 27395 0 30743 3378 1 52310 58855 0 59905 3467 0 60227 44700 0 4466 13169 0 11289 35510 1 45259 23426 1 55348 47991 1 48231 26070 1 48525 16062 1 57931 14114 1 27522 12180 0 12757 20313 1 42080 63292 0 26595 51845...
output:
81918
result:
ok 1 number(s): "81918"
Test #30:
score: 0
Accepted
time: 183ms
memory: 36544kb
input:
65534 98300 13270 32154 0 55961 42311 1 28791 53182 1 59289 50275 1 8038 50111 1 26166 35350 1 11126 60403 1 39908 858 0 59214 30194 1 35679 36357 1 3720 42580 1 24721 42253 1 39094 30603 1 6697 51066 0 3419 63371 1 64362 40934 1 51257 14082 1 63044 59478 1 20968 167 1 30514 42744 1 41849 32144 1 16...
output:
81918
result:
ok 1 number(s): "81918"
Test #31:
score: 0
Accepted
time: 157ms
memory: 37632kb
input:
100000 98302 61966 27142 0 53993 68970 0 34298 58099 1 63874 66725 0 14229 34649 0 2188 81478 0 11724 47884 0 19350 71019 0 61938 51579 0 35352 84486 0 84906 82998 0 14543 39824 0 48746 90624 0 40191 40994 1 47705 23039 0 62784 79792 0 15245 88212 0 92737 95500 0 94811 43930 1 69757 74299 0 53560 49...
output:
116384
result:
ok 1 number(s): "116384"
Test #32:
score: 0
Accepted
time: 196ms
memory: 37660kb
input:
100000 98302 63951 83046 0 49356 1318 1 76776 11042 0 10897 51960 0 91740 36201 1 79579 70160 0 48233 7988 1 77589 73526 0 64917 41777 1 25721 24712 1 40519 61024 0 44493 67177 0 33335 24084 0 3709 42347 0 79762 84853 0 19590 61141 0 77360 58976 0 72886 44054 0 26544 51830 0 5866 45365 0 76622 26661...
output:
124574
result:
ok 1 number(s): "124574"
Test #33:
score: 0
Accepted
time: 158ms
memory: 37600kb
input:
100000 98302 88683 65853 1 85733 28420 1 76008 55360 1 49391 24933 1 87657 14404 1 90800 58622 1 75122 69522 1 22879 73168 1 9291 55797 0 50874 91259 1 86132 9922 1 39521 5711 1 75332 50647 1 14679 89034 1 15252 65542 1 26783 18217 1 11499 26206 1 10487 12140 1 69139 5819 1 62356 90026 1 82272 78670...
output:
116384
result:
ok 1 number(s): "116384"
Test #34:
score: 0
Accepted
time: 332ms
memory: 66084kb
input:
96000 144000 69465 78015 0 70940 79248 0 21267 22945 0 42324 69262 0 92079 61298 0 14312 89231 0 76879 64390 0 9515 87921 0 72921 56907 0 77360 7365 0 5845 31109 0 50706 19916 0 29274 5084 0 27393 91084 0 89690 81434 0 81818 17371 0 59817 87334 0 40802 63933 0 34255 67445 0 84919 73480 0 6355 64057 ...
output:
96000
result:
ok 1 number(s): "96000"
Test #35:
score: 0
Accepted
time: 465ms
memory: 66408kb
input:
98000 147000 64116 52839 0 58466 64469 1 68501 33965 1 35430 29683 1 18936 7790 1 11024 87600 0 87090 27191 1 3526 40531 1 8967 64385 0 74728 9321 1 14888 6420 0 27780 41446 0 56978 5452 0 13425 79329 1 87611 32959 0 3067 17931 0 22989 82933 1 24468 5242 0 47124 59392 1 79914 93411 1 87124 90315 1 7...
output:
98000
result:
ok 1 number(s): "98000"
Test #36:
score: 0
Accepted
time: 320ms
memory: 66600kb
input:
100000 150000 56602 2395 1 82739 49727 1 27928 35973 1 98253 71027 1 35442 98024 1 18060 72579 1 86277 73382 1 47014 51013 1 65310 17335 1 54892 30774 1 77960 822 1 47490 41910 1 62706 85890 1 71056 13146 1 34092 33865 1 58748 46635 1 21972 37259 1 51199 31504 1 43608 87941 1 90790 42330 1 50214 189...
output:
100000
result:
ok 1 number(s): "100000"
Test #37:
score: 0
Accepted
time: 327ms
memory: 66052kb
input:
95000 142500 89254 6524 0 87399 92742 0 50117 8349 0 76363 58825 0 52190 83971 0 6795 20007 0 79651 49566 0 10970 79953 0 11980 53524 0 7467 38087 0 32096 9083 0 17827 38927 0 79988 23057 0 17001 32129 0 56030 42010 0 77569 59418 0 70155 41087 0 27648 77230 0 21167 61067 0 56132 86455 0 80647 19119 ...
output:
95000
result:
ok 1 number(s): "95000"
Test #38:
score: 0
Accepted
time: 441ms
memory: 66456kb
input:
97000 145500 94330 53090 1 74854 79436 0 31002 6670 1 20802 11748 0 23526 78897 0 2600 84830 0 19572 95411 1 87783 55713 0 20454 22602 1 30751 12787 0 67094 60165 0 9477 19434 1 91443 58645 0 49984 1623 0 44709 41427 0 1043 24331 1 79185 42581 0 25102 27915 0 67200 90145 1 25416 40396 1 35961 3087 0...
output:
97000
result:
ok 1 number(s): "97000"
Test #39:
score: 0
Accepted
time: 317ms
memory: 66484kb
input:
99000 148500 63457 58943 1 22274 81761 1 72574 63452 1 67950 79564 1 42979 37610 1 30695 97830 1 33234 77173 1 84106 7156 1 40075 39589 1 41001 66646 1 68993 48814 1 19560 49612 1 80409 70249 1 5995 75043 1 78335 53789 1 87696 94760 1 32934 22366 1 64938 22623 1 49846 19013 1 96854 6968 1 6539 63262...
output:
99000
result:
ok 1 number(s): "99000"
Extra Test:
score: 0
Extra Test Passed