QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#75469 | #5458. Shortest Path Query | tute7627 | AC ✓ | 222ms | 336812kb | C++17 | 13.3kb | 2023-02-05 12:09:20 | 2024-06-21 12:37:00 |
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(10)
#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;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
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;}
template< typename T = int >
struct edge {
int to;
T cost;
int id;
edge():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;
}
using I = long long;
struct Point{
I x, y;
Point(): x(0), y(0){}
Point(I x,I y):x(x),y(y){}
Point &operator+=(const Point &p){
x += p.x, y += p.y;
return *this;
}
Point &operator-=(const Point &p){
x -= p.x, y -= p.y;
return *this;
}
Point &operator*=(I v){
x *= v, y *= v;
return *this;
}
Point &operator/=(I v){
assert(x % v == 0 && y % v == 0);
x /= v, y /= v;
return *this;
}
friend Point operator+(const Point &l, const Point &r){
return Point(l) += r;
}
friend Point operator-(const Point &l, const Point &r){
return Point(l) -= r;
}
friend Point operator*(const Point &l, I r){
return Point(l) *= r;
}
friend Point operator/(const Point &l, I r){
return Point(l) /= r;
}
bool operator<(const Point &p)const{
if(x == p.x)return y < p.y;
return x < p.x;
}
bool operator>(const Point &p) const{
if(x == p.x)return y > p.y;
return x > p.x;
}
bool operator==(const Point &p)const{return x == p.x && y == p.y;}
bool operator!=(const Point &p)const{return x != p.x || y != p.y;}
friend ostream &operator<<(ostream &os, const Point &p) {
return os << "(" << p.x << "," << p.y << ")";
}
friend istream &operator>>(istream &is, Point &p) {
is >> p.x >> p.y;
return (is);
}
};
struct Line{
Point a,b;
Line() = default;
Line(Point a, Point b) : a(a), b(b){}
};
I norm(const Point &p){
return p.x * p.x + p.y * p.y;
}
I dot(const Point &a, const Point &b){
return a.x * b.x + a.y * b.y;
}
I cross(const Point &a, const Point &b){
return a.x * b.y - a.y * b.x;
}
I distance(const Point &a, const Point &b){
return norm(a - b);
}
I area(const Point &a,const Point &b,const Point &c){
return abs(cross(b-a,c-a));
}
constexpr int COUNTER_CLOCKWISE = +1;
constexpr int CLOCKWISE = -1;
constexpr int ONLINE_BACK = +2; // c-a-b
constexpr int ONLINE_FRONT = -2; // a-b-c
constexpr int ON_SEGMENT = 0; // a-c-b
int ccw(const Point &a, Point b, Point c) {
b = b - a, c = c - a;
if(cross(b, c) > 0) return COUNTER_CLOCKWISE;
if(cross(b, c) < 0) return CLOCKWISE;
if(dot(b, c) < 0) return ONLINE_BACK;
if(norm(b) < norm(c)) return ONLINE_FRONT;
return ON_SEGMENT;
}
bool parallel(const Line &a, const Line &b){
return cross(a.b - a.a, b.b - b.a) == 0;
}
bool orthogonal(const Line &a, const Line &b){
return dot(a.a - a.b, b.a - b.b) == 0;
}
bool argument_compare(Point a, Point b){
if(a.x == 0 && a.y == 0)a.x = 1;
if(b.x == 0 && b.y == 0)b.x = 1;
if(a.y < 0 && b.y >= 0){
return true;
}
else if(a.y >= 0 && b.y < 0){
return false;
}
else if(a.y == 0 && b.y == 0){
return a.x >= 0 && b.x < 0;
}
return cross(a, b) > 0;
}
vector<Point>convex_hull(const vector<Point>&points, bool onEdge = false){
int n = points.size(), k = 0;
auto p = points;
const I limit = onEdge ? 0 : 1;
if(n <= 2)return p;
sort(p.begin(), p.end());
vector<Point> ch(2 * n);
for(int i = 0; i < n; ch[k++] = p[i++]) {
while(k >= 2 && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < limit) --k;
}
for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]) {
while(k >= t && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < limit) --k;
}
ch.resize(k - 1);
return ch;
}
vector<Point>lower_convex_hull(const vector<Point>&points, bool onEdge = false){
auto p = points;
sort(p.begin(), p.end());
vector<Point>q;
q.reserve(p.size());
for(auto z:p){
if(q.empty()||q.back().y>z.y){
q.PB(z);
}
}
swap(p,q);
const I limit = onEdge ? 0 : 1;
int n = p.size(), k = 0;
if(n <= 2)return p;
vector<Point> ch(2 * n);
for(int i = 0; i < n; ch[k++] = p[i++]) {
while(k >= 2 && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < limit) --k;
}
ch.resize(k);
return ch;
}
//各b_jに対して、cross(a_i,b_j)の最大値を求める
vector<I>get_cross_max(vector<Point>a,vector<Point>b){
a = convex_hull(a, false);
vector<int>ord(b.size());
iota(ord.begin(),ord.end(),0);
sort(ord.begin(),ord.end(),[&](int i,int j){return argument_compare(b[i],b[j]);});
vector<I>ret(b.size());
if(norm(b[ord[0]]) == 0 && norm(b[ord.back()]) == 0){
return ret;
}
int start = 0;
while(norm(b[ord[start]]) == 0)start++;
int max_arg = 0;
for(int i = 1; i < a.size(); i++){
if(cross(a[max_arg], b[ord[start]]) < cross(a[i], b[ord[start]])){
max_arg = i;
}
}
for(auto i:ord){
while(1){
I c0 = cross(a[(max_arg == 0 ? a.size() - 1 : max_arg - 1)],b[i]);
I c1 = cross(a[max_arg],b[i]);
I c2 = cross(a[(max_arg == a.size() - 1 ? 0 : max_arg + 1)],b[i]);
if(c0 <= c1 && c1 >= c2)break;
max_arg++;
if(max_arg >= a.size())max_arg -= a.size();
}
ret[i] = cross(a[max_arg], b[i]);
}
return ret;
}
vector<I>get_cross_min(vector<Point>a,vector<Point>b){
for(auto &p:b)p *= -1;
auto ret = get_cross_max(a, b);
for(auto &r:ret)r *= -1;
return ret;
}
vector<I>get_dot_max(vector<Point>a,vector<Point>b){
for(auto &p:b){
p = Point(-p.y, p.x);
}
auto ret=get_cross_max(a,b);
return ret;
}
// 多角形と点の包含判定
enum {
OUT, ON, IN
};
using Polygon=vector<Point>;
int contains(const Polygon &Q, const Point &p) {
bool in = false;
for(int i = 0; i < Q.size(); i++) {
Point a = Q[i] - p, b = Q[(i + 1) % Q.size()] - p;
if(a.y > b.y) swap(a, b);
if(a.y <= 0 && 0 < b.y && cross(a, b) < 0) in = !in;
if(cross(a, b) == 0 && dot(a, b) <= 0) return ON;
}
return in ? IN : OUT;
}
bool segment_intersect(const Line &s, const Line &t) {
return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
bool segmnent_point_intersect(const Line &s, const Point &p) {
return ccw(s.a, s.b, p) == 0;
}
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;
auto g=readGraph<int>(n,m,1,true,true);
vector<vector<Point>>dp(n);
dp[0].EB(0,0);
rep(i,0,n){
dp[i]=lower_convex_hull(dp[i]);
OUT(dp[i]);
for(auto e:g[i]){
for(auto p:dp[i]){
dp[e.to].EB(p.x+(e.cost==0),p.y+(e.cost==1));
}
}
}
int q;cin>>q;
while(q--){
ll a,b,x;cin>>a>>b>>x;x--;
ll ret=INF;
for(auto z:dp[x]){
chmin(ret,a*z.x+b*z.y);
}
cout<<ret<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
input:
4 4 1 2 0 1 3 1 2 4 0 3 4 1 3 3 5 2 3 2 4 2 3 4
output:
3 4 4
result:
ok 3 number(s): "3 4 4"
Test #2:
score: 0
Accepted
time: 59ms
memory: 26324kb
input:
50000 100000 1 2 1 2 3 0 3 4 1 4 5 0 5 6 1 6 7 0 7 8 1 8 9 1 9 10 0 10 11 1 11 12 1 12 13 1 13 14 0 14 15 0 15 16 0 16 17 0 17 18 1 18 19 1 19 20 0 20 21 1 21 22 0 22 23 0 23 24 1 24 25 1 25 26 0 26 27 1 27 28 0 28 29 0 29 30 0 30 31 0 31 32 1 32 33 0 33 34 1 34 35 1 35 36 1 36 37 1 37 38 0 38 39 0 ...
output:
164602050 208733870 228180204 248456409 87574800 16685198 46684062 64713954 46949896 240633535 94777502 83016099 259833741 167838804 214963500 147454419 111021650 80187604 184782450 78138570 86528820 203553394 188095596 202049239 290053220 172790198 168899028 97757186 96431009 266952297 164349486 26...
result:
ok 50000 numbers
Test #3:
score: 0
Accepted
time: 79ms
memory: 55644kb
input:
50000 100000 1 2 1 2 3 0 3 4 1 4 5 0 5 6 0 6 7 1 7 8 0 8 9 0 9 10 1 10 11 1 11 12 1 12 13 1 13 14 0 14 15 1 15 16 1 16 17 1 17 18 0 18 19 0 19 20 1 20 21 1 21 22 1 22 23 0 23 24 0 24 25 1 25 26 1 26 27 0 27 28 0 28 29 1 29 30 0 30 31 1 31 32 1 32 33 1 33 34 0 34 35 1 35 36 1 36 37 1 37 38 0 38 39 0 ...
output:
100196045 31414400 96903432 4429901 131353947 100466556 96621590 116427456 86564241 138309577 111227766 96757449 98894394 113624940 103437724 32090169 118889544 27383865 145395709 52415186 44958306 178247166 101837390 123750212 66411806 29005113 61920301 53700468 83473964 101048973 24035890 82224385...
result:
ok 50000 numbers
Test #4:
score: 0
Accepted
time: 107ms
memory: 71952kb
input:
50000 100000 1 2 1 2 3 1 3 4 1 4 5 1 5 6 1 6 7 1 7 8 0 8 9 0 9 10 0 10 11 1 11 12 0 12 13 0 13 14 1 14 15 0 15 16 1 16 17 0 17 18 0 18 19 1 19 20 0 20 21 0 21 22 0 22 23 0 23 24 1 24 25 1 25 26 0 26 27 1 27 28 1 28 29 0 29 30 0 30 31 1 31 32 1 32 33 1 33 34 1 34 35 1 35 36 1 36 37 1 37 38 0 38 39 1 ...
output:
41086586 22479083 65941117 52313422 27188549 98552837 41170647 18070874 39704907 37300025 33494097 12541197 85953980 97466762 54255520 55975530 82137682 80760412 36734523 80227468 57771407 53423371 35392992 38772417 24348238 129485865 50694526 41529532 35522018 64188507 64483980 20809109 88158268 62...
result:
ok 50000 numbers
Test #5:
score: 0
Accepted
time: 174ms
memory: 118876kb
input:
50000 100000 1 2 0 2 3 0 3 4 1 4 5 1 5 6 1 6 7 1 7 8 1 8 9 0 9 10 1 10 11 1 11 12 1 12 13 0 13 14 1 14 15 0 15 16 1 16 17 0 17 18 0 18 19 0 19 20 0 20 21 0 21 22 0 22 23 0 23 24 1 24 25 1 25 26 1 26 27 1 27 28 1 28 29 0 29 30 1 30 31 1 31 32 0 32 33 0 33 34 1 34 35 0 35 36 0 36 37 0 37 38 0 38 39 0 ...
output:
21363040 19817072 33235630 2642743 12734703 31561956 16868881 12347713 34007395 31539206 21812869 11469295 13583164 35332256 19432281 13050400 27543307 30865175 23535331 10932941 10731700 8935711 32438529 30147704 11201224 15475486 18918233 29097672 1865520 1717197 10847438 17918300 9085519 22377502...
result:
ok 50000 numbers
Test #6:
score: 0
Accepted
time: 183ms
memory: 118296kb
input:
50000 100000 1 2 1 2 3 1 3 4 1 4 5 1 5 6 1 6 7 0 7 8 1 8 9 0 9 10 1 10 11 0 11 12 1 12 13 0 13 14 1 14 15 0 15 16 1 16 17 1 17 18 0 18 19 1 19 20 1 20 21 1 21 22 0 22 23 1 23 24 0 24 25 0 25 26 0 26 27 0 27 28 0 28 29 0 29 30 1 30 31 1 31 32 0 32 33 0 33 34 0 34 35 1 35 36 1 36 37 1 37 38 0 38 39 1 ...
output:
7034164 2604311 9210306 13276159 7323558 11457505 5477798 10888155 4546292 13775110 4723690 3315532 7247352 14850537 8847725 7929292 5197554 2059467 7544756 2500593 3970752 12419699 9568962 4563223 10626816 3277034 12260607 6928168 4303017 5299690 8738156 9317082 9746787 10042419 13632702 8481147 11...
result:
ok 50000 numbers
Test #7:
score: 0
Accepted
time: 164ms
memory: 77736kb
input:
50000 100000 1 2 1 2 3 1 3 4 1 4 5 0 5 6 0 6 7 0 7 8 1 8 9 0 9 10 0 10 11 1 11 12 1 12 13 0 13 14 1 14 15 0 15 16 1 16 17 1 17 18 0 18 19 1 19 20 0 20 21 0 21 22 0 22 23 1 23 24 1 24 25 0 25 26 1 26 27 1 27 28 0 28 29 1 29 30 1 30 31 1 31 32 0 32 33 1 33 34 1 34 35 0 35 36 1 36 37 1 37 38 1 38 39 1 ...
output:
2881748 379663 1968885 883510 1429377 1317566 1691388 425238 1498644 703328 976532 252540 2157673 2046415 2184358 1823525 1052010 1808512 1132815 987060 2350191 1248681 2155738 502600 2363042 1527856 2063953 1042845 914460 1787808 1741740 1992040 730062 1592241 1369515 1084786 1140249 2712241 754218...
result:
ok 50000 numbers
Test #8:
score: 0
Accepted
time: 95ms
memory: 34852kb
input:
50000 100000 1 2 1 2 3 1 3 4 0 4 5 1 5 6 1 6 7 0 7 8 0 8 9 1 9 10 1 10 11 0 11 12 0 12 13 1 13 14 1 14 15 1 15 16 1 16 17 1 17 18 0 18 19 1 19 20 1 20 21 1 21 22 0 22 23 0 23 24 1 24 25 0 25 26 1 26 27 1 27 28 1 28 29 0 29 30 0 30 31 0 31 32 1 32 33 1 33 34 0 34 35 1 35 36 0 36 37 0 37 38 1 38 39 1 ...
output:
196425 220970 672134 128953 248040 374496 332056 388195 69312 404828 506828 470044 440937 427759 304069 412812 560795 698232 549476 191135 57468 173200 255364 763568 250616 668286 251232 71252 152194 430194 671010 10672 671999 197794 308836 393499 324938 191963 182472 234993 495528 453559 86128 9629...
result:
ok 50000 numbers
Test #9:
score: 0
Accepted
time: 101ms
memory: 36684kb
input:
50000 100000 1 2 1 2 3 1 3 4 1 4 5 1 5 6 1 6 7 0 7 8 0 8 9 0 9 10 0 10 11 1 11 12 0 12 13 1 13 14 0 14 15 0 15 16 1 16 17 1 17 18 0 18 19 1 19 20 1 20 21 0 21 22 1 22 23 1 23 24 0 24 25 0 25 26 0 26 27 0 27 28 0 28 29 0 29 30 0 30 31 0 31 32 1 32 33 0 33 34 1 34 35 1 35 36 0 36 37 0 37 38 0 38 39 1 ...
output:
468255 105020 312484 469028 46500 433476 348092 241180 416482 136152 497776 571977 530352 219162 562176 138675 705269 353652 287899 214580 13380 294272 27828 132826 749244 506820 295440 417272 370316 114926 552490 6486 834970 359255 601821 208311 337232 101539 489665 169404 93039 64173 382258 775608...
result:
ok 50000 numbers
Test #10:
score: 0
Accepted
time: 82ms
memory: 33588kb
input:
50000 100000 1 2 0 2 3 0 3 4 0 4 5 0 5 6 1 6 7 1 7 8 0 8 9 1 9 10 1 10 11 1 11 12 0 12 13 1 13 14 0 14 15 0 15 16 1 16 17 1 17 18 1 18 19 0 19 20 0 20 21 0 21 22 1 22 23 0 23 24 1 24 25 0 25 26 0 26 27 0 27 28 0 28 29 0 29 30 0 30 31 0 31 32 0 32 33 0 33 34 1 34 35 1 35 36 0 36 37 0 37 38 0 38 39 1 ...
output:
663010 158597 758130 682380 443574 514836 623881 348012 155945 542531 400539 240444 166313 307926 556860 383720 97095 367865 372270 204195 787005 79165 455970 495416 156456 33165 223166 481715 416854 524138 316025 105263 274806 781025 177352 653420 491795 743770 506808 72480 505734 444805 198372 700...
result:
ok 50000 numbers
Test #11:
score: 0
Accepted
time: 31ms
memory: 14216kb
input:
50000 99998 1 2 0 1 2 1 2 3 0 2 3 1 3 4 0 3 4 1 4 5 0 4 5 1 5 6 0 5 6 1 6 7 0 6 7 1 7 8 0 7 8 1 8 9 0 8 9 1 9 10 0 9 10 1 10 11 0 10 11 1 11 12 0 11 12 1 12 13 0 12 13 1 13 14 0 13 14 1 14 15 0 14 15 1 15 16 0 15 16 1 16 17 0 16 17 1 17 18 0 17 18 1 18 19 0 18 19 1 19 20 0 19 20 1 20 21 0 20 21 1 21...
output:
357392852 286944261 25899482 106697866 266744665 188046239 246595068 282194356 149697006 36449271 55148897 105197896 112647747 361542769 153346933 426991460 799984 17749645 256444871 329993400 275444491 344593108 81998360 305443891 233695326 82148357 92148157 17449651 36449271 34349313 175796484 354...
result:
ok 50000 numbers
Test #12:
score: 0
Accepted
time: 222ms
memory: 336812kb
input:
50000 50299 1 2 0 2 3 0 3 4 0 4 5 0 5 6 0 6 7 0 7 8 0 8 9 0 9 10 0 10 11 0 11 12 0 12 13 0 13 14 0 14 15 0 15 16 0 16 17 0 17 18 0 18 19 0 19 20 0 20 21 0 21 22 0 22 23 0 23 24 0 24 25 0 25 26 0 26 27 0 27 28 0 28 29 0 29 30 0 30 31 0 31 32 0 32 33 0 33 34 0 34 35 0 35 36 0 36 37 0 37 38 0 38 39 0 3...
output:
28885380 45069427 33432760 30206043 5611707 40119773 20814082 10397200 11616787 7910426 49163370 9368174 31732491 43615079 41538187 27076798 41917819 32019460 17871476 14080806 5899035 42800174 14990686 29049896 25022003 9316314 27915136 19878279 43675167 30658188 2990993 2704160 12805154 19507614 5...
result:
ok 50000 numbers