QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#502378 | #125. Wild Boar | Rafi22 | 62 | 5352ms | 766608kb | C++20 | 4.8kb | 2024-08-03 04:54:47 | 2024-08-03 04:54:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif
#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=1000000007;
const int N=2007,pot=1<<17;
vector<pair<pair<int,int>,ll>>seg[2*pot+7];
bool is[2*pot+7];
void upd(int v)
{
seg[v].clear();
if(!is[2*v+1])
{
seg[v]=seg[2*v];
return ;
}
int a,b;
ll mn=infl;
vector<pair<int,int>>xd;
for(auto [pl,cl]:seg[2*v])
{
for(auto [pr,cr]:seg[2*v+1])
{
if(pl.nd!=pr.st&&cl+cr<mn)
{
mn=cl+cr;
a=pl.st;
b=pr.nd;
}
}
}
if(mn!=infl)
{
seg[v].pb({{a,b},mn});
xd.pb({a,b});
}
auto add=[&](int xa,int ya)
{
int x,y;
mn=infl;
for(auto [pl,cl]:seg[2*v])
{
for(auto [pr,cr]:seg[2*v+1])
{
bool nie=0;
for(auto [xx,yy]:xd) if(pl.st==xx&&pr.nd==yy) nie=1;
if(nie) continue;
if(pl.st!=xa&&pr.nd!=ya&&pl.nd!=pr.st&&cl+cr<mn)
{
mn=cl+cr;
x=pl.st;
y=pr.nd;
}
}
}
if(mn!=infl)
{
seg[v].pb({{x,y},mn});
xd.pb({x,y});
}
};
add(a,b);
add(a,b);
add(a,b);
add(a,b);
add(a,-1);
add(a,-1);
add(-1,b);
add(-1,b);
}
vector<pair<pair<int,int>,ll>>T[N][N];
ll g[N][N];
vector<pair<int,ll>>G[N];
int U[2*N],V[2*N],C[2*N];
int X[pot];
ll dis[N][N];
ll D[2*N];
vector<pair<ll,int>>W[N][N];
bool odw[2*N];
void ins(int v)
{
v+=pot-1;
while(v>1)
{
v/=2;
upd(v);
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,m,q,L;
cin>>n>>m>>q>>L;
FOR(i,1,m)
{
cin>>V[i]>>U[i]>>C[i];
V[i+m]=U[i];
U[i+m]=V[i];
C[i+m]=C[i];
g[U[i]][V[i]]=C[i];
g[V[i]][U[i]]=C[i];
G[V[i]].pb({U[i],i});
G[V[i+m]].pb({U[i+m],i+m});
}
FOR(i,1,n)
{
for(auto [j,t]:G[i])
{
FOR(l,1,2*m) D[l]=infl;
memset(odw,0,sizeof odw);
D[t]=0;
priority_queue<pair<ll,int>>Q;
Q.push({0,t});
while(sz(Q)>0)
{
int v=Q.top().nd;
Q.pop();
if(odw[v]) continue;
odw[v]=1;
W[j][U[v]].pb({D[v],V[v]});
for(auto [u,tu]:G[U[v]])
{
if(abs(v-tu)==m) continue;
if(D[v]+C[tu]<D[tu])
{
D[tu]=D[v]+C[tu];
Q.push({-D[tu],tu});
}
}
}
FOR(l,1,n) sort(all(W[j][l]));
}
FOR(j,1,n)
{
if(i==j) continue;
int a,b;
ll mn=infl;
if(g[i][j])
{
a=j,b=i;
mn=g[i][j];
}
vector<pair<int,int>>xd;
for(auto [A,ta]:G[i])
{
for(auto [B,tb]:G[j])
{
dis[A][B]=infl;
if(sz(W[A][B])>0&&W[A][B][0].nd!=j) dis[A][B]=W[A][B][0].st;
else if(sz(W[A][B])>1) dis[A][B]=W[A][B][1].st;
debug(i,j,A,B,dis[A][B]);
if(C[ta]+dis[A][B]+C[tb]<mn)
{
mn=C[ta]+dis[A][B]+C[tb];
a=A;
b=B;
}
}
}
if(mn!=infl)
{
debug(i,j,mn);
T[i][j].pb({{a,b},mn});
xd.pb({a,b});
}
auto add = [&](int xa,int ya)
{
mn=infl;
int x,y;
if(g[i][j]&&j!=xa&&i!=ya)
{
bool nie=0;
for(auto [xx,yy]:xd) if(j==xx&&i==yy) nie=1;
if(!nie)
{
mn=g[i][j];
x=j;
y=i;
}
}
for(auto [A,ta]:G[i])
{
if(A==xa) continue;
for(auto [B,tb]:G[j])
{
if(B==ya) continue;
bool nie=0;
for(auto [xx,yy]:xd) if(A==xx&&B==yy) nie=1;
if(nie) continue;
if(C[ta]+dis[A][B]+C[tb]<mn)
{
mn=C[ta]+dis[A][B]+C[tb];
x=A;
y=B;
}
}
}
if(mn!=infl)
{
T[i][j].pb({{x,y},mn});
xd.pb({x,y});
}
};
add(a,b);
add(a,b);
add(a,b);
add(a,b);
add(a,-1);
add(a,-1);
add(-1,b);
add(-1,b);
}
for(auto [j,t]:G[i]) FOR(l,1,n) W[j][l].clear();
}
FOR(i,1,L) cin>>X[i];
FOR(i,1,L-1)
{
is[i+pot-1]=1;
seg[i+pot-1]=T[X[i]][X[i+1]];
}
ROF(i,pot-1,1)
{
is[i]=is[2*i];
upd(i);
}
while(q--)
{
int i;
cin>>i>>X[i];
if(i>1)
{
seg[i-1+pot-1]=T[X[i-1]][X[i]];
ins(i-1);
}
if(i<L)
{
seg[i+pot-1]=T[X[i]][X[i+1]];
ins(i);
}
FOR(i,1,L-1) debug(X[i],X[i+1],seg[i+pot-1]);
ll ans=infl;
for(auto [p,x]:seg[1]) ans=min(ans,x);
if(ans==infl) cout<<-1<<endl;
else cout<<ans<<endl;
}
return 0;
}
详细
Subtask #1:
score: 12
Accepted
Test #1:
score: 12
Accepted
time: 7ms
memory: 14536kb
input:
5 5 1 10 1 4 10 2 4 2 2 5 4 3 5 4 4 5 7 2 4 5 3 5 3 5 4 2 1 10 1
output:
-1
result:
ok single line: '-1'
Test #2:
score: 12
Accepted
time: 5ms
memory: 12656kb
input:
5 10 1 10 1 2 8 1 3 5 1 4 2 1 5 1 2 3 7 2 4 9 2 5 6 3 4 10 3 5 10 4 5 6 4 2 4 3 5 3 1 4 3 5 3 5
output:
64
result:
ok single line: '64'
Test #3:
score: 12
Accepted
time: 7ms
memory: 11932kb
input:
5 10 1 10 1 2 8 1 3 4 1 4 2 1 5 10 2 3 10 2 4 10 2 5 6 3 4 10 3 5 2 4 5 10 5 1 2 1 4 5 1 5 3 1 8 4
output:
60
result:
ok single line: '60'
Test #4:
score: 12
Accepted
time: 5ms
memory: 14624kb
input:
6 10 1 10 1 3 3 1 4 5 1 5 9 1 6 10 2 3 4 2 5 5 2 6 1 3 6 4 4 6 6 5 6 8 4 3 6 4 1 3 6 4 3 5 1 1
output:
48
result:
ok single line: '48'
Test #5:
score: 12
Accepted
time: 3ms
memory: 11504kb
input:
6 10 1 10 1 2 10 1 3 9 1 5 6 1 6 9 2 4 3 2 5 4 2 6 9 3 5 2 4 5 6 4 6 8 4 6 2 3 2 3 1 3 5 4 9 1
output:
86
result:
ok single line: '86'
Test #6:
score: 12
Accepted
time: 10ms
memory: 14116kb
input:
6 10 1 10 1 2 7 1 4 10 1 5 9 1 6 9 2 3 7 2 4 3 3 4 1 3 5 4 4 6 2 5 6 3 6 3 1 3 6 4 6 4 3 1 5 2
output:
61
result:
ok single line: '61'
Test #7:
score: 12
Accepted
time: 11ms
memory: 14488kb
input:
7 10 1 10 1 2 4 1 3 8 1 5 10 1 7 5 2 5 5 2 7 4 3 4 8 3 6 9 4 7 6 5 6 9 2 1 2 1 2 1 2 1 2 1 9 2
output:
56
result:
ok single line: '56'
Test #8:
score: 12
Accepted
time: 6ms
memory: 11744kb
input:
7 10 1 10 1 4 8 1 5 9 1 6 5 1 7 5 2 4 1 2 6 9 2 7 6 3 5 5 3 7 2 5 6 7 6 5 3 4 6 3 6 4 7 4 4 4
output:
88
result:
ok single line: '88'
Test #9:
score: 12
Accepted
time: 6ms
memory: 11132kb
input:
7 10 1 10 1 3 1 1 4 5 1 5 8 2 3 4 2 7 9 3 4 8 3 7 5 4 5 1 5 6 8 6 7 2 6 5 2 5 6 5 6 5 7 6 4 3
output:
84
result:
ok single line: '84'
Test #10:
score: 12
Accepted
time: 9ms
memory: 11128kb
input:
7 10 1 10 1 3 4 1 4 3 1 5 7 1 6 5 1 7 2 2 3 8 2 4 6 4 7 7 5 6 10 6 7 4 3 2 3 1 3 1 3 1 3 2 9 3
output:
90
result:
ok single line: '90'
Test #11:
score: 12
Accepted
time: 10ms
memory: 12736kb
input:
8 10 1 10 1 2 4 1 7 4 1 8 7 2 3 7 2 4 2 3 7 5 3 8 8 4 5 5 5 6 5 6 8 3 3 5 7 5 6 3 5 3 6 4 9 2
output:
105
result:
ok single line: '105'
Test #12:
score: 12
Accepted
time: 7ms
memory: 14360kb
input:
8 10 1 10 1 3 6 1 7 3 1 8 1 2 3 10 2 4 6 2 8 9 3 5 3 4 6 5 5 7 7 6 8 7 5 2 6 8 4 5 2 5 3 6 10 7
output:
114
result:
ok single line: '114'
Test #13:
score: 12
Accepted
time: 5ms
memory: 12844kb
input:
8 10 1 10 1 2 6 1 3 9 1 6 7 2 8 6 3 5 10 4 6 4 4 7 1 4 8 8 5 7 7 6 8 9 2 8 5 6 2 3 5 6 4 8 3 5
output:
125
result:
ok single line: '125'
Test #14:
score: 12
Accepted
time: 7ms
memory: 14180kb
input:
8 10 1 10 1 2 5 1 5 8 1 8 3 2 6 5 2 7 8 3 4 5 3 8 4 4 6 4 5 6 1 5 7 5 7 4 5 1 6 4 7 4 8 6 10 1
output:
99
result:
ok single line: '99'
Test #15:
score: 12
Accepted
time: 9ms
memory: 11356kb
input:
9 10 1 10 1 3 1 1 6 6 1 9 6 2 4 5 2 9 3 3 5 4 4 5 10 6 7 6 7 8 8 8 9 6 3 5 2 6 2 8 5 1 3 7 2 8
output:
189
result:
ok single line: '189'
Test #16:
score: 12
Accepted
time: 10ms
memory: 12672kb
input:
9 10 1 10 1 8 9 1 9 5 2 6 8 2 7 10 3 5 8 3 7 5 4 5 3 4 8 4 5 9 7 6 9 9 4 7 5 2 7 5 8 4 6 1 7 2
output:
217
result:
ok single line: '217'
Test #17:
score: 12
Accepted
time: 3ms
memory: 12872kb
input:
9 10 1 10 1 4 8 1 9 10 2 3 3 2 5 10 3 9 1 4 8 5 5 7 6 6 7 2 6 8 7 8 9 10 2 9 6 4 5 8 6 3 9 3 4 7
output:
116
result:
ok single line: '116'
Test #18:
score: 12
Accepted
time: 10ms
memory: 11932kb
input:
9 10 1 10 1 3 6 1 4 1 2 4 1 2 6 7 3 4 6 3 9 1 5 6 2 5 8 6 7 8 8 7 9 9 1 6 7 6 9 7 1 5 9 3 7 6
output:
155
result:
ok single line: '155'
Test #19:
score: 12
Accepted
time: 7ms
memory: 12804kb
input:
10 10 1 10 1 3 6 1 9 5 2 4 4 2 6 2 3 4 10 5 8 1 5 10 7 6 7 8 7 10 2 8 9 8 10 3 10 9 1 2 8 4 7 4 2 3
output:
196
result:
ok single line: '196'
Test #20:
score: 12
Accepted
time: 5ms
memory: 13996kb
input:
10 10 1 10 1 4 5 1 8 6 2 8 9 2 9 7 3 9 4 3 10 3 4 7 5 5 6 10 5 10 10 6 7 8 9 5 4 6 5 8 2 8 9 8 3 9
output:
284
result:
ok single line: '284'
Test #21:
score: 12
Accepted
time: 10ms
memory: 11036kb
input:
5 10 1 10 1 2 1 1 3 7 1 4 6 1 5 10 2 3 2 2 4 4 2 5 5 3 4 1 3 5 10 4 5 3 2 1 5 1 4 2 5 4 1 5 7 5
output:
45
result:
ok single line: '45'
Test #22:
score: 12
Accepted
time: 10ms
memory: 11760kb
input:
5 10 1 10 1 2 4 1 3 10 1 4 5 1 5 6 2 3 2 2 4 1 2 5 1 3 4 9 3 5 10 4 5 10 4 2 3 1 4 3 1 3 2 3 10 1
output:
49
result:
ok single line: '49'
Test #23:
score: 12
Accepted
time: 11ms
memory: 14584kb
input:
5 10 1 10 1 2 10 1 3 8 1 4 2 1 5 10 2 3 7 2 4 2 2 5 4 3 4 3 3 5 7 4 5 1 3 1 2 4 5 4 3 2 5 2 10 2
output:
41
result:
ok single line: '41'
Test #24:
score: 12
Accepted
time: 7ms
memory: 14240kb
input:
5 10 1 10 1 2 7 1 3 7 1 4 4 1 5 8 2 3 6 2 4 10 2 5 1 3 4 9 3 5 4 4 5 6 1 4 3 1 2 4 2 1 2 4 1 2
output:
70
result:
ok single line: '70'
Test #25:
score: 12
Accepted
time: 7ms
memory: 12580kb
input:
5 10 1 10 1 2 10 1 3 8 1 4 9 1 5 3 2 3 3 2 4 3 2 5 10 3 4 1 3 5 1 4 5 7 4 3 1 3 4 2 4 5 2 3 9 2
output:
36
result:
ok single line: '36'
Test #26:
score: 12
Accepted
time: 5ms
memory: 14096kb
input:
5 10 1 10 1 2 5 1 3 7 1 4 2 1 5 6 2 3 5 2 4 2 2 5 8 3 4 8 3 5 3 4 5 1 3 2 5 4 1 2 4 3 1 2 2 2
output:
38
result:
ok single line: '38'
Subtask #2:
score: 35
Accepted
Dependency #1:
100%
Accepted
Test #27:
score: 35
Accepted
time: 8ms
memory: 11780kb
input:
20 40 1 100 1 9 61 1 17 2 1 20 2 2 8 35 2 16 11 2 17 4 3 5 19 3 18 52 4 5 4 4 6 89 4 11 52 5 6 59 5 10 77 5 12 24 5 13 82 5 16 55 5 18 25 6 7 98 6 9 59 6 15 37 7 10 42 7 17 71 8 10 37 8 19 31 9 10 74 9 14 25 9 15 70 9 18 39 10 14 1 11 20 46 12 17 48 12 20 36 13 17 32 13 20 77 14 18 73 15 16 50 15 17...
output:
8152
result:
ok single line: '8152'
Test #28:
score: 35
Accepted
time: 18ms
memory: 23624kb
input:
100 100 1 100000 1 8 471117256 1 62 130027795 1 73 656848900 2 37 768343489 2 79 60152578 3 39 730756132 3 91 742436424 4 14 127206074 4 26 49752186 4 37 277130591 5 39 267794148 5 67 795814790 6 26 322818374 7 9 528203057 7 22 321028016 7 74 603723430 8 48 173910965 9 56 146180110 9 84 468273541 9 ...
output:
-1
result:
ok single line: '-1'
Test #29:
score: 35
Accepted
time: 25ms
memory: 25648kb
input:
100 100 1 100000 1 22 496690411 1 80 160170813 2 78 246401127 2 79 698301891 3 18 335424010 3 43 199212643 4 8 387887272 5 63 342214421 5 89 493693783 6 12 43866762 7 25 965696870 8 67 293983530 9 71 213899161 10 93 733230250 10 97 886418929 11 28 387081262 11 62 181334144 12 27 278789468 12 49 7986...
output:
-1
result:
ok single line: '-1'
Test #30:
score: 35
Accepted
time: 609ms
memory: 65316kb
input:
100 300 1 100000 1 5 365304469 1 9 179648504 1 34 59704152 1 46 817333375 2 5 583565204 2 9 785103102 2 40 480198908 2 47 835927550 2 48 354380031 2 65 486715288 2 92 950313228 2 93 374483314 3 30 82337560 3 32 308293283 3 60 646076359 3 97 197337851 4 16 366616801 4 18 585876058 4 29 61422451 4 41 ...
output:
93114286907830
result:
ok single line: '93114286907830'
Test #31:
score: 35
Accepted
time: 596ms
memory: 66396kb
input:
100 300 1 100000 1 3 912986539 1 9 197792176 1 13 246835129 1 16 344867075 1 18 967911416 1 19 441622270 1 22 775263613 1 29 968144880 1 34 820331077 1 36 757601901 1 51 502350836 1 63 474234541 1 64 113420408 1 66 153943653 1 67 199823271 1 72 138370407 1 82 774858096 1 83 139129019 1 90 916684302 ...
output:
35572091890278
result:
ok single line: '35572091890278'
Test #32:
score: 35
Accepted
time: 490ms
memory: 63008kb
input:
100 300 1 100000 1 2 314864312 1 3 280386699 1 5 900829806 1 6 286123321 1 7 662490056 1 8 717445306 1 9 388158739 1 15 820246487 1 17 380616676 1 19 118295437 1 20 278592968 1 21 38694483 1 23 405950418 1 27 271185615 1 28 124119023 1 31 138766045 1 35 4292030 1 36 699435130 1 38 115953700 1 39 635...
output:
12727469493056
result:
ok single line: '12727469493056'
Test #33:
score: 35
Accepted
time: 516ms
memory: 66788kb
input:
100 300 1 100000 1 2 523087200 1 3 8625758 1 4 479922033 1 5 179521367 1 6 52560042 1 7 647680332 1 8 10574482 1 9 420818013 1 10 443941068 1 11 265762494 1 12 880093987 1 13 984518118 1 14 551970324 1 15 328833026 1 16 906486091 1 17 985112084 1 18 478403683 1 21 344890629 1 23 180458589 1 25 23751...
output:
6812101494149
result:
ok single line: '6812101494149'
Test #34:
score: 35
Accepted
time: 553ms
memory: 66584kb
input:
150 300 1 100000 1 57 878207960 1 93 703334538 1 101 68840341 2 9 609874540 2 14 524137107 2 30 948045570 2 38 438159917 2 98 989192311 3 42 257559234 3 75 152187092 3 148 440131087 4 28 567615969 4 46 776359152 4 54 179042810 4 125 426404592 5 50 265179533 5 66 877325657 5 75 700145090 5 99 1205793...
output:
156796709032107
result:
ok single line: '156796709032107'
Test #35:
score: 35
Accepted
time: 586ms
memory: 67268kb
input:
150 300 1 100000 1 16 202605724 1 34 111505563 1 76 802050519 1 95 522857534 1 97 217611266 1 124 553211647 2 84 23122883 2 106 665133149 3 83 800041101 3 89 488010281 3 142 376710381 3 148 559320220 4 7 338847173 4 26 682077064 4 36 501041950 4 58 301859723 4 62 257257630 4 68 394915954 4 131 73298...
output:
158718457185257
result:
ok single line: '158718457185257'
Test #36:
score: 35
Accepted
time: 384ms
memory: 69080kb
input:
150 300 1 100000 1 2 131562815 1 3 383393237 1 5 252538693 1 7 236824663 1 8 689269584 1 10 247469848 1 11 461280494 1 12 598561583 1 15 183046296 1 17 586816553 1 18 896988909 1 19 388930811 1 20 420628667 1 21 768353228 1 24 880805200 1 25 469471039 1 27 177584827 1 30 1802821 1 32 1752197 1 35 56...
output:
12477242437185
result:
ok single line: '12477242437185'
Test #37:
score: 35
Accepted
time: 451ms
memory: 69944kb
input:
150 300 1 100000 1 3 397335916 1 9 149871467 1 11 906429160 1 12 907834891 1 13 95045117 1 15 123378294 1 19 130873916 1 20 784547300 1 23 579232016 1 24 692840149 1 25 429494420 1 29 256646966 1 30 25479873 1 33 98932677 1 35 747188673 1 39 24829208 1 40 655452971 1 42 859426866 1 46 619182596 1 47...
output:
35395680659889
result:
ok single line: '35395680659889'
Test #38:
score: 35
Accepted
time: 595ms
memory: 68760kb
input:
150 300 1 100000 1 42 727058849 1 49 349708043 1 57 999809570 1 88 336747661 2 8 587959218 2 31 588457404 3 94 829049410 3 98 102020218 3 144 187783209 3 149 182448561 4 55 89240698 4 75 832327090 4 100 34796121 5 8 936264949 5 61 710383076 5 77 556268363 5 101 23917938 6 50 600701047 6 82 262234386...
output:
153201692683735
result:
ok single line: '153201692683735'
Test #39:
score: 35
Accepted
time: 420ms
memory: 63968kb
input:
200 300 1 100000 1 19 909805577 1 97 582775452 2 27 43163990 2 30 442296779 2 66 878591352 2 89 513837579 2 151 277200957 3 64 985251429 3 79 641905693 3 133 215658546 4 34 748196928 4 174 11100110 4 189 225851894 5 136 24998123 5 150 416236971 5 177 571026362 6 28 147828956 6 58 678254484 6 79 9310...
output:
255201255583268
result:
ok single line: '255201255583268'
Test #40:
score: 35
Accepted
time: 501ms
memory: 74216kb
input:
200 300 1 100000 1 11 50543344 1 26 175124937 1 29 726988619 1 30 489727785 1 41 707658243 1 47 64703458 1 50 222132616 1 51 278508318 1 52 495534006 1 56 449020704 1 63 303036406 1 73 356701920 1 83 898919082 1 89 767068839 1 94 894349166 1 100 57693820 1 108 31975726 1 112 232178142 1 117 61458064...
output:
53584398972763
result:
ok single line: '53584398972763'
Test #41:
score: 35
Accepted
time: 448ms
memory: 64564kb
input:
200 300 1 100000 1 32 792158817 1 137 25487399 1 155 772268784 2 63 941831574 2 98 105568022 2 156 239332109 3 92 253866448 3 122 672259455 4 9 713111912 4 19 598402833 4 30 820316864 4 114 680217866 4 152 424095465 5 48 68970188 5 143 24731629 5 156 770600892 6 119 588905532 6 133 82848267 7 38 167...
output:
267939841388462
result:
ok single line: '267939841388462'
Test #42:
score: 35
Accepted
time: 427ms
memory: 64376kb
input:
200 300 1 100000 1 22 535223654 1 142 603041735 1 186 192207208 2 44 367710248 2 55 79901099 2 134 986616264 2 182 726190801 2 193 614388294 3 28 689728406 3 71 854707789 3 100 420300867 4 51 684428208 4 85 157443457 4 94 844010383 4 118 273611275 4 200 149184217 5 29 695523255 5 52 946678086 5 61 3...
output:
268285977186522
result:
ok single line: '268285977186522'
Test #43:
score: 35
Accepted
time: 369ms
memory: 76408kb
input:
230 300 1 100000 1 2 742794410 1 3 728150284 1 20 401244033 1 21 70310741 1 34 667555409 1 36 594171145 1 42 544498443 1 61 257894401 1 84 687337304 1 85 965200707 1 86 807054423 1 93 963823263 1 99 443314390 1 107 31267844 1 108 547633577 1 111 556970671 1 118 213208555 1 125 840297483 1 129 958611...
output:
77172557277251
result:
ok single line: '77172557277251'
Test #44:
score: 35
Accepted
time: 264ms
memory: 64096kb
input:
250 300 1 100000 1 49 326167568 1 92 930782713 2 37 160107383 2 237 551533701 3 53 917311888 3 152 600286392 4 112 737862953 4 126 372037561 5 150 129855862 5 237 978322168 6 244 595435111 6 250 476977898 7 11 514404625 7 84 157813656 8 89 111824040 8 204 121230607 9 119 495099315 9 133 136354536 10...
output:
465520766059970
result:
ok single line: '465520766059970'
Test #45:
score: 35
Accepted
time: 256ms
memory: 61212kb
input:
250 300 1 100000 1 23 151374420 1 200 605870388 2 180 472093518 2 195 765657780 2 237 771384939 3 25 369658311 3 38 603813994 3 139 427985331 4 23 767911031 4 45 556624664 4 87 128653888 5 20 730849760 5 92 226785250 5 153 905678103 6 68 334063497 6 111 673737490 6 160 783223392 7 66 918450016 7 122...
output:
479631977494206
result:
ok single line: '479631977494206'
Test #46:
score: 35
Accepted
time: 56ms
memory: 46572kb
input:
300 300 1 100000 1 61 987580639 1 132 274493980 2 137 135288592 2 230 869989040 3 78 757256421 3 180 679335221 4 7 306075219 4 69 816734920 5 128 626849350 5 283 709406225 6 57 72516811 6 230 104732523 7 252 57223906 8 148 780817506 8 217 209842564 9 68 133059571 9 117 456949134 10 33 787824292 10 3...
output:
7275932816495946
result:
ok single line: '7275932816495946'
Subtask #3:
score: 15
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #47:
score: 15
Accepted
time: 198ms
memory: 35928kb
input:
200 500 1 50 1 11 34 1 32 97 1 43 30 1 55 96 1 89 88 1 92 51 1 108 16 1 121 86 2 45 64 2 51 8 2 62 60 2 73 44 2 100 74 2 117 70 2 128 15 2 178 31 2 181 5 2 189 21 3 5 77 3 166 99 4 23 6 4 33 37 4 140 42 4 198 67 5 35 38 5 39 60 5 77 38 5 109 51 6 41 2 6 86 72 6 97 66 6 116 39 6 133 42 6 147 12 6 160...
output:
5847
result:
ok single line: '5847'
Test #48:
score: 15
Accepted
time: 5352ms
memory: 201868kb
input:
500 2000 1 100000 1 2 799202998 1 3 70814651 1 4 166275349 1 5 551769444 1 7 461096012 1 8 534263628 1 9 151173730 1 10 221493187 1 11 838959315 1 12 761142835 1 13 280847539 1 14 896759219 1 15 754519641 1 17 171545812 1 19 50980387 1 21 67949479 1 22 786655275 1 23 649900813 1 26 770954979 1 27 21...
output:
6260410251443
result:
ok single line: '6260410251443'
Test #49:
score: 15
Accepted
time: 4970ms
memory: 318340kb
input:
800 2000 1 100000 1 2 157655669 1 4 446875712 1 6 808513252 1 7 472781188 1 10 982637200 1 11 947266908 1 12 699315534 1 16 917785011 1 18 136547621 1 19 250495719 1 20 704288203 1 21 632177911 1 25 662352820 1 27 593914743 1 28 418593433 1 37 966961557 1 40 424284254 1 42 77342498 1 43 930525301 1 ...
output:
8915394679509
result:
ok single line: '8915394679509'
Test #50:
score: 15
Accepted
time: 4168ms
memory: 422072kb
input:
1000 2000 1 100000 1 2 43852398 1 4 998331786 1 5 300298846 1 6 898256294 1 7 561869420 1 12 427770772 1 16 144859407 1 20 474895449 1 22 737471836 1 28 400459485 1 29 119781325 1 31 866262817 1 33 442263306 1 34 973833212 1 37 280414788 1 42 456644193 1 44 143876334 1 52 601989530 1 60 289694925 1 ...
output:
20910390822664
result:
ok single line: '20910390822664'
Test #51:
score: 15
Accepted
time: 4418ms
memory: 429020kb
input:
1000 2000 1 100000 1 3 80139289 1 5 694390674 1 12 281351538 1 19 218941977 1 20 781420637 1 22 83740959 1 31 53795060 1 32 364432226 1 33 224860380 1 34 183746897 1 49 756786619 1 60 677808436 1 61 481907479 1 66 185098737 1 69 237903106 1 70 792522463 1 71 521669135 1 75 425602948 1 77 384108521 1...
output:
11915895659094
result:
ok single line: '11915895659094'
Test #52:
score: 15
Accepted
time: 4714ms
memory: 437508kb
input:
1000 2000 1 100000 1 9 373112932 1 12 492765708 1 13 760131920 1 17 865389518 1 19 148453513 1 24 877280379 1 26 612591153 1 28 176497954 1 29 750685211 1 30 807441139 1 35 886076004 1 40 14700143 1 42 669637100 1 43 751249546 1 44 86823878 1 46 654427170 1 47 380290294 1 49 608820075 1 50 715504409...
output:
8073476690431
result:
ok single line: '8073476690431'
Test #53:
score: 15
Accepted
time: 4157ms
memory: 472444kb
input:
1000 2000 1 100000 1 146 265539242 1 787 717806900 2 99 561024983 2 169 107802796 2 785 829863913 2 908 823173936 3 395 682748856 3 605 892930129 3 688 666831100 3 822 261525980 4 49 559136539 4 81 804262295 4 671 66923572 4 988 95129764 5 153 457428795 5 446 608860803 5 461 205883700 5 488 13976357...
output:
202357340046894
result:
ok single line: '202357340046894'
Test #54:
score: 15
Accepted
time: 4135ms
memory: 474104kb
input:
1000 2000 1 100000 1 189 61544008 1 202 833875544 1 382 488985253 1 791 788764390 2 251 249163022 2 266 774363438 2 718 332703034 3 360 885118875 3 547 364974317 3 564 430424783 3 628 364170814 4 418 901229360 4 908 631145277 4 924 259640666 5 492 377251143 5 852 746602647 5 950 587205889 6 278 5408...
output:
206504918353028
result:
ok single line: '206504918353028'
Test #55:
score: 15
Accepted
time: 4124ms
memory: 471884kb
input:
1000 2000 1 100000 1 33 929637740 1 75 314877121 1 138 595420872 1 233 254859751 1 656 726999907 2 108 631045151 2 209 997704061 2 437 745202445 2 654 184933128 3 223 609597986 3 422 841134009 4 467 219314329 4 683 814689784 5 48 258724221 5 409 571452027 5 671 228089274 5 729 406155949 5 977 315180...
output:
200417247718197
result:
ok single line: '200417247718197'
Test #56:
score: 15
Accepted
time: 4135ms
memory: 471788kb
input:
1000 2000 1 100000 1 767 430895017 1 797 267085094 1 973 622445896 2 296 79132601 2 479 50554076 2 523 334478127 2 672 231873549 2 679 129843346 2 742 570837413 2 887 385332205 3 146 269967303 3 198 545188271 3 228 565599702 3 392 932969710 4 571 999759097 4 612 676610647 4 654 623927938 4 746 92855...
output:
204182375564076
result:
ok single line: '204182375564076'
Test #57:
score: 15
Accepted
time: 4066ms
memory: 523760kb
input:
1100 2000 1 100000 1 158 637074501 1 710 801051626 1 711 367839843 2 394 125561622 2 469 753634911 2 477 903083519 2 582 51405118 2 805 194609222 2 1035 605598466 3 139 331028746 3 223 676486992 3 265 724513122 3 598 977792611 3 750 361496304 4 494 21948003 4 772 995462320 5 183 427259770 5 530 7804...
output:
234310995770405
result:
ok single line: '234310995770405'
Test #58:
score: 15
Accepted
time: 4040ms
memory: 579032kb
input:
1200 2000 1 100000 1 45 151494925 1 682 648656677 1 908 414659342 1 1016 180092461 2 679 85708627 2 935 531780507 3 202 436578842 3 493 608617128 3 580 597384984 3 674 19517914 3 916 758869724 3 946 803680525 4 144 639968873 4 415 75434207 4 483 287746137 5 7 935028002 5 883 532965939 5 977 54459873...
output:
269372989829770
result:
ok single line: '269372989829770'
Test #59:
score: 15
Accepted
time: 3880ms
memory: 616832kb
input:
1300 2000 1 100000 1 223 392856121 1 251 988204834 1 266 191975770 1 1101 867087024 2 419 964619471 2 536 717781131 3 475 471335293 3 624 772971819 3 864 446100456 4 246 817374327 4 330 862505744 4 1183 432822797 5 174 280870091 5 1232 318738592 6 376 818047549 6 1263 868069815 7 32 730357755 7 617 ...
output:
310833304137352
result:
ok single line: '310833304137352'
Test #60:
score: 15
Accepted
time: 3679ms
memory: 663368kb
input:
1400 2000 1 100000 1 519 148871372 1 626 135017978 1 1018 311404266 1 1293 569095501 2 244 39379604 2 559 173787504 2 602 549225069 3 408 745467718 3 968 328583573 4 458 200860996 4 617 567811912 5 603 802582193 5 755 426514096 5 1041 949791055 5 1222 575741188 6 680 436418752 6 1275 370759373 7 263...
output:
376566604923396
result:
ok single line: '376566604923396'
Test #61:
score: 15
Accepted
time: 3562ms
memory: 695048kb
input:
1500 2000 1 100000 1 33 526554653 1 210 761496655 1 1104 208216601 2 345 42001698 2 491 661745186 3 1317 158328332 3 1416 749606015 4 822 693343634 4 843 384433391 5 912 212780833 5 1063 669130099 6 299 850466423 6 864 906431506 6 1268 19276072 7 282 710707542 7 993 183112457 8 603 150241498 8 774 7...
output:
458407341914078
result:
ok single line: '458407341914078'
Test #62:
score: 15
Accepted
time: 3531ms
memory: 727388kb
input:
1600 2000 1 100000 1 985 854841087 1 1017 266804611 2 1201 609703497 2 1332 482417893 2 1450 970392724 3 337 945242535 3 947 464154808 4 318 117668664 4 393 442342159 4 1089 18044226 5 33 213672536 5 1124 131475550 5 1218 290844477 6 334 503456759 6 468 38229989 7 458 940244814 7 1591 884854788 8 12...
output:
530052270631724
result:
ok single line: '530052270631724'
Test #63:
score: 15
Accepted
time: 3057ms
memory: 749884kb
input:
1700 2000 1 100000 1 576 862037604 1 1189 678849245 1 1273 717325711 1 1337 609356680 1 1459 997427218 2 172 903345156 2 874 191796681 3 1555 738444242 3 1600 339240620 4 748 447350463 4 1489 168143773 5 214 88025905 5 657 7295054 6 193 183309142 6 1159 553302939 7 1629 579349540 7 1689 534075287 8 ...
output:
698028432533845
result:
ok single line: '698028432533845'
Test #64:
score: 15
Accepted
time: 2926ms
memory: 766608kb
input:
1800 2000 1 100000 1 496 892547386 1 812 528881635 2 566 632443282 2 1437 138577557 3 755 81394128 3 1627 480232269 4 16 456204401 4 1259 841014721 5 462 397926678 5 1383 776538144 6 51 124625414 6 1074 576608956 7 565 58701272 7 1305 123890496 8 1271 248799423 8 1686 603850241 9 118 243035053 9 154...
output:
1005496863510461
result:
ok single line: '1005496863510461'
Test #65:
score: 15
Accepted
time: 1117ms
memory: 583200kb
input:
2000 2000 1 100000 1 1297 145010449 1 1451 709684521 2 1777 703537272 2 1883 655550186 3 909 635782270 3 1137 954354936 4 8 260474719 4 1972 804193154 5 139 150768703 5 1118 575210945 6 522 165247783 6 1059 205797802 7 295 911581510 7 359 332372682 8 126 128591703 9 1280 381287018 9 1360 576864790 1...
output:
48367867260844863
result:
ok single line: '48367867260844863'
Test #66:
score: 15
Accepted
time: 1129ms
memory: 583148kb
input:
2000 2000 1 100000 1 468 618113821 1 835 172940688 2 940 769098252 2 1058 802227358 3 1405 915334495 3 1566 764903283 4 641 808779005 4 1777 698210047 5 298 357942478 5 829 276145193 6 635 51027656 6 1790 34075486 7 263 449378656 7 1542 740653110 8 632 651885025 8 1666 977131526 9 239 284584144 9 12...
output:
47843251504395645
result:
ok single line: '47843251504395645'
Subtask #4:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #67:
score: 38
Accepted
time: 486ms
memory: 52736kb
input:
20 40 100 100000 1 6 987 1 11 783 2 3 25 2 4 228 2 7 11 2 9 803 2 18 330 3 15 926 3 17 258 4 11 809 4 14 948 4 16 540 5 10 861 5 14 832 6 9 502 6 12 687 6 17 336 6 20 388 7 14 954 7 20 113 8 11 587 8 13 407 8 16 605 8 20 329 9 10 449 9 11 440 9 13 432 9 16 789 10 16 86 11 15 252 11 16 349 11 17 892 ...
output:
107301632 107302149 107303013 107301244 107302691 107302951 107304338 107304338 107304846 107303692 107305412 107304754 107304236 107303329 107303329 107303329 107303993 107302638 107304665 107304665 107304568 107302231 107304099 107305036 107304575 107304296 107306324 107306227 107306227 107306179 ...
result:
ok 100 lines
Test #68:
score: 38
Accepted
time: 361ms
memory: 141720kb
input:
1000 1000 100000 100 1 742 707 2 829 519 3 336 990 4 720 747 5 286 427 5 773 720 6 19 838 6 201 475 6 711 58 6 983 299 7 536 660 8 235 219 8 913 56 9 195 694 9 350 253 10 200 201 10 253 174 10 573 640 10 869 279 11 508 123 11 886 810 12 838 926 13 369 704 13 539 46 13 689 869 14 488 484 14 539 204 1...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 100000 lines
Test #69:
score: 38
Accepted
time: 1035ms
memory: 429720kb
input:
2000 2000 100 100 1 515 666448701 1 1649 401098309 2 640 673004164 2 1167 33862589 2 1616 878538685 3 625 895349391 4 137 298302337 4 529 112653749 5 8 635484125 5 888 297855613 6 1108 224194833 7 160 949536424 9 233 413793897 10 1732 920527660 11 1403 612800874 12 166 277916402 12 872 391982103 12 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
result:
ok 100 lines
Test #70:
score: 38
Accepted
time: 1169ms
memory: 433476kb
input:
2000 2000 100000 100 1 1435 253445557 2 631 777646389 2 1284 186676412 3 1301 91918649 3 1877 927193900 4 284 888629880 5 723 67489022 5 1114 258850137 5 1674 499297658 5 1996 413672729 6 296 972959491 6 1437 630485632 7 1910 133683202 8 308 682674983 8 447 384301247 8 887 852962869 8 931 874976511 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 100000 lines
Test #71:
score: 38
Accepted
time: 1228ms
memory: 438424kb
input:
2000 2000 100000 100000 1 1835 815996124 1 1927 608300753 2 931 362028647 3 71 430265560 3 846 594795523 3 946 168542632 4 90 321492297 4 1896 132057014 5 968 260169013 5 1082 44612095 5 1426 770836502 6 690 474171960 7 1066 990178722 8 1245 149242691 9 431 824468570 9 476 395470089 9 1056 281805333...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 100000 lines
Test #72:
score: 0
Time Limit Exceeded
input:
500 2000 100000 100000 1 2 797279819 1 3 396668877 1 4 296077915 1 6 494595090 1 7 55792672 1 8 324776562 1 9 214135792 1 11 624900642 1 13 254906979 1 17 908611552 1 19 673124924 1 20 617627682 1 21 207404085 1 22 317273834 1 23 593047669 1 25 231303314 1 27 983833690 1 28 502882158 1 29 554792402 ...
output:
8287405792922 8287342955203 8287414097952 8287414097952 8287477362531 8287481998593 8287375870894 8287411130255 8287385865008 8287349905484 8287385865008 8287447089779 8287366513390 8287366513390 8287366513390 8287397136689 8287348222253 8287348222253 8287348222253 8287317598954 8287226416410 828711...