QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#335169 | #8232. Yet Another Shortest Path Query | ucup-team134 | ML | 2499ms | 1008080kb | C++14 | 7.7kb | 2024-02-22 20:37:11 | 2024-02-22 20:37:12 |
Judging History
answer
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
const int mod=998244353;
inline int add(int x,int y){int ret=x+y;if(ret>=mod)ret-=mod;return ret;}
inline int sub(int x,int y){int ret=x-y;if(ret<0)ret+=mod;return ret;}
inline int mul(int x,int y){return ((ll)x*y)%mod;}
inline int step(int base,int pw){int ret=1;while(pw){if(pw&1)ret=mul(ret,base);base=mul(base,base);pw>>=1;}return ret;}
inline int invv(int x){return step(x,mod-2);}
const int maxn=1e6+10;
const double max_load_cap=0.2;
int inf=1e9;
struct chash{
const uint64_t C= (ll)(4e18*acos(0))|71;
ll operator()(ll x)const{return __builtin_bswap64(x*C);}
};
vector<pii>vg[maxn],vout[maxn],vin[maxn];
vector<int>niz,revniz;
unordered_map<int,int,chash>map_out[maxn],map_in[maxn],map_rez[maxn];
int n,m,deg[maxn],pos[maxn],q,rez_qry[maxn];
void init(){
for(int i=1;i<=n;i++){
map_out[i].max_load_factor(max_load_cap);
map_in[i].max_load_factor(max_load_cap);
map_rez[i].max_load_factor(max_load_cap);
for(int j=0;j<vout[i].size();j++)map_out[i][vout[i][j].ff]=vout[i][j].ss;
for(int j=0;j<vin[i].size();j++)map_in[i][vin[i][j].ff]=vin[i][j].ss;
///printf("%d %d AAA\n",i,niz[i]);
}
}
void prek(){
vector<int>good;
for(int i=1;i<=n;i++){
if(deg[i]<=5)good.pb(i);
}
niz.pb(0);
revniz.resize(n+1);
for(int i=1;i<=n;i++){
int id=good.back();
good.pop_back();
niz.pb(id);
revniz[id]=niz.size()-1;
pos[id]=1;
for(int j=0;j<vg[id].size();j++){
int id2=vg[id][j].ff;
if(pos[id2])continue;
deg[id2]--;
if(deg[id2]==5)good.pb(id2);
}
///printf("%d %d MAP\n",i,id);
}
for(int i=1;i<=n;i++){
for(int j=0;j<vg[i].size();j++){
int id=vg[i][j].ff;
int w=vg[i][j].ss;
int a=revniz[i];
int b=revniz[id];
if(a>b){
continue;
}
vout[a].pb({b,w});
vin[b].pb({a,w});
}
}
}
void update_rez(int a,int b,int w){
if(a>b)swap(a,b);
if(map_rez[a].find(b)==map_rez[a].end())map_rez[a][b]=w;
else{
int &p=map_rez[a][b];
p=min(p,w);
}
}
void go_LR(){
for(int i=1;i<=n;i++){
for(int j=0;j<vout[i].size();j++){
int id1=vout[i][j].ff;
int w1=vout[i][j].ss;
update_rez(i,id1,w1);
for(int k=j+1;k<vout[i].size();k++){
int id2=vout[i][k].ff;
int w2=vout[i][k].ss;
update_rez(id1,id2,w1+w2);
}
}
}
}
void go_lrr_llr(){
for(int i=1;i<=n;i++){
for(int j=0;j<vout[i].size();j++){
int id1=vout[i][j].ff;
int w1=vout[i][j].ss;
for(int k=0;k<vout[i].size();k++){
int id2=vout[i][k].ff;
if(id2==id1)continue;
int w2=vout[i][k].ss;
for(int p=0;p<vout[id2].size();p++){
int id3=vout[id2][p].ff;
int w3=vout[id2][p].ss;
///printf("%d %d %d %d AAA\n",i,id1,id2,id3);
update_rez(id1,id3,w1+w2+w3);
}
}
}
}
}
struct qry{
int a,b,w,id;
}pocqry[maxn];
vector<qry>newqry;
void go_make_k2(){
for(int i=1;i<=q;i++){
int a=pocqry[i].a;
int b=pocqry[i].b;
qry pom2;
pom2.id=i;
pom2.a=a;
pom2.b=b;
pom2.w=0;
newqry.pb(pom2);
for(int j=0;j<vout[a].size();j++){
int id=vout[a][j].ff;
int w=vout[a][j].ss;
qry pom;
pom.id=pocqry[i].id;
pom.w=w;
pom.a=id;
pom.b=b;
///printf("%d %d EDGE A\n",pom.a,pom.b);
if(pom.a>pom.b)swap(pom.a,pom.b);
newqry.pb(pom);
}
for(int j=0;j<vout[b].size();j++){
int id=vout[b][j].ff;
int w=vout[b][j].ss;
qry pom;
pom.id=pocqry[i].id;
pom.w=w;
pom.a=a;
pom.b=id;
///printf("%d %d EDGE B\n",pom.a,pom.b);
if(pom.a>pom.b)swap(pom.a,pom.b);
newqry.pb(pom);
}
}
/*for(int i=0;i<newqry.size();i++){
printf("%d %d %d %d NQ\n",newqry[i].a,newqry[i].b,newqry[i].id,newqry[i].w);
}*/
}
void go_upd_LR_k2(){
return;
for(int i=0;i<newqry.size();i++){
if(map_rez[newqry[i].a].find(newqry[i].b)!=map_rez[newqry[i].a].end())
rez_qry[newqry[i].id]=min(rez_qry[newqry[i].id],map_rez[newqry[i].a][newqry[i].b]+newqry[i].w);
}
}
void go_RR_k2(){
for(int i=1;i<=n;i++){
for(int j=0;j<vin[i].size();j++){
for(int k=0;k<vout[i].size();k++){
int id1=vin[i][j].ff;
int id2=vout[i][k].ff;
int w1=vin[i][j].ss;
int w2=vout[i][k].ss;
///printf("%d %d |");
update_rez(id1,id2,w1+w2);
}
}
}
for(int i=0;i<newqry.size();i++){
if(map_rez[newqry[i].a].find(newqry[i].b)!=map_rez[newqry[i].a].end()){
rez_qry[newqry[i].id]=min(rez_qry[newqry[i].id],map_rez[newqry[i].a][newqry[i].b]+newqry[i].w);
///printf("%d %d | %d %d ADDED\n",newqry[i].a,newqry[i].b,newqry[i].w,map_rez[newqry[i].a][newqry[i].b]);
}
}
}
void go_RL_k2(){
for(int i=0;i<newqry.size();i++){
int id=newqry[i].id;
int a=newqry[i].a;
int b=newqry[i].b;
int w=newqry[i].w;
for(int j=0;j<vout[a].size();j++){
int id2=vout[a][j].ff;
int w2=vout[a][j].ss;
if(map_in[id2].find(b)!=map_in[id2].end())
rez_qry[id]=min(rez_qry[id],w2+w+map_in[id2][b]);
}
}
}
void dfs(int x,int h,int goal,int cw,int &ret){
if(goal==x){
ret=min(ret,cw);
return;
}
if(h==0)return;
for(int i=0;i<vg[x].size();i++){
int id=vg[x][i].ff;
dfs(id,h-1,goal,cw+vg[x][i].ss,ret);
}
}
int get_qry(int a,int b){
int ret=inf;
dfs(a,3,b,0,ret);
if(ret==inf)return -1;
return ret;
}
int rpqa[maxn],rpqb[maxn];
int main(){
///freopen("test.txt","r",stdin);
scanf("%d %d",&n,&m);
for(int i=1;i<=m;i++){
int a,b,w;
scanf("%d %d %d",&a,&b,&w);
vg[a].pb({b,w});
vg[b].pb({a,w});
deg[a]++;
deg[b]++;
}
prek();
init();
go_LR();
scanf("%d",&q);
for(int i=1;i<=q;i++){
rez_qry[i]=inf;
int a,b;
scanf("%d %d",&a,&b);
rpqa[i]=a;
rpqb[i]=b;
a=revniz[a];
b=revniz[b];
if(a>b)swap(a,b);
pocqry[i].id=i;
pocqry[i].a=a;
pocqry[i].b=b;
pocqry[i].w=0;
}
go_make_k2();
go_upd_LR_k2();
go_RR_k2();
go_RL_k2();
go_lrr_llr();
for(int i=1;i<=q;i++){
int a=pocqry[i].a;
int b=pocqry[i].b;
if(map_rez[a].find(b)!=map_rez[a].end())rez_qry[i]=min(rez_qry[i],map_rez[a][b]);
if(rez_qry[i]==inf)rez_qry[i]=-1;
printf("%d\n",rez_qry[i]);
//printf("%d REAL\n",get_qry(rpqa[i],rpqb[i]));
/*if(rez_qry[i]!=get_qry(rpqa[i],rpqb[i])){
printf("%d %d %d\n",i,rez_qry[i],get_qry(rpqa[i],rpqb[i]));
}*/
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 48ms
memory: 273940kb
input:
6 9 1 2 4 2 3 6 3 6 5 6 5 3 5 4 2 4 1 3 3 4 9 1 3 100 5 3 1 5 1 3 1 6 3 4 3 5 2 5
output:
6 8 3 1 7
result:
ok 5 number(s): "6 8 3 1 7"
Test #2:
score: 0
Accepted
time: 47ms
memory: 273740kb
input:
6 4 1 2 1 2 3 1 3 4 1 4 5 1 3 1 4 1 5 1 6
output:
3 -1 -1
result:
ok 3 number(s): "3 -1 -1"
Test #3:
score: 0
Accepted
time: 818ms
memory: 494436kb
input:
40005 79608 1 2 70031203 1 3 99924845 1 4 61645659 1 5 9324967 2 3 15761918 3 4 62534796 4 5 35260314 5 2 35948540 6 2 23727405 6 7 83302920 7 3 31010426 7 8 75060393 8 4 94275932 8 9 99663793 9 5 81701979 9 6 439297 10 6 46955645 10 11 89514237 11 7 21257310 11 12 53896253 12 8 67933315 12 13 26161...
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 1000000 numbers
Test #4:
score: 0
Accepted
time: 741ms
memory: 487844kb
input:
35479 70156 1 2 53094201 1 3 95796673 1 4 35585979 1 5 55612594 2 3 60766083 3 4 64392832 4 5 32896460 5 2 91649893 6 2 6196154 6 7 4986564 7 3 91799790 7 8 10909791 8 4 30034265 8 9 95672010 9 4 67004237 9 10 77872672 10 5 68900058 10 6 42927604 11 6 71288663 11 12 51597962 12 7 79690815 12 13 9742...
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 1000000 numbers
Test #5:
score: 0
Accepted
time: 767ms
memory: 489124kb
input:
35811 70820 1 2 40434193 1 3 13483892 1 4 32864259 1 5 47591755 1 6 65123023 1 7 81695948 1 8 1102880 1 9 47223939 1 10 52947058 1 11 31439481 2 3 94162364 3 4 20590842 4 5 24137043 5 6 74926235 6 7 9376267 7 8 97130364 8 9 75568799 9 10 5022411 10 11 59066963 11 2 96177033 12 2 17823959 12 13 83906...
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 1000000 numbers
Test #6:
score: 0
Accepted
time: 2086ms
memory: 971284kb
input:
200000 599952 127401 69434 88680591 127401 39916 10673559 127401 52475 59546013 127401 77787 74018113 127401 11462 7023970 60723 37187 65141305 60723 115008 72307785 60723 71812 47362248 60723 143858 20042617 60723 153890 48502784 60723 172009 21754689 60723 23327 97998405 63817 58332 30056889 63817...
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 1000000 numbers
Test #7:
score: 0
Accepted
time: 2106ms
memory: 973524kb
input:
200000 599962 127401 36130 68347938 127401 56107 50001021 127401 35011 47850437 127401 166086 58628679 127401 167575 97121890 127401 150008 97636763 127401 148173 79875436 60723 38275 3780759 60723 75775 69051390 60723 93280 43415633 60723 108525 89666833 60723 119851 80916915 60723 134418 23881201 ...
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 1000000 numbers
Test #8:
score: 0
Accepted
time: 2094ms
memory: 972216kb
input:
200000 599957 127401 62215 44179748 127401 96198 78839479 127401 81659 96992357 127401 105920 13674618 127401 192829 54389653 60723 66329 69331527 60723 139474 14904280 60723 186870 86233097 60723 134036 31587848 60723 161658 81495543 60723 156381 83635122 60723 187612 77920441 60723 189714 55041890...
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 1000000 numbers
Test #9:
score: 0
Accepted
time: 788ms
memory: 492108kb
input:
35011 70019 1 2 65752645 2 3 52997572 3 4 14100539 4 5 78562579 5 6 99655664 6 7 26904774 7 8 88411503 8 9 89420520 9 10 88149169 10 11 53207001 11 12 16506048 12 13 37143703 13 14 1295901 14 15 61139259 15 16 79880287 16 17 4390087 17 18 2733598 18 19 48969502 19 20 77562639 20 21 53171540 21 22 36...
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 1000000 numbers
Test #10:
score: 0
Accepted
time: 836ms
memory: 642220kb
input:
50000 99997 1 2 5460409 2 3 95815999 3 4 17091945 4 5 91580749 5 6 91717493 6 7 55420828 7 8 10603109 8 9 62048169 9 10 28446542 10 11 38346952 11 12 66167473 12 13 80749600 13 14 20348320 14 15 5868535 15 16 45627426 16 17 2445360 17 18 21766361 18 19 20516369 19 20 8226530 20 21 86609482 21 22 134...
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 1000000 numbers
Test #11:
score: 0
Accepted
time: 576ms
memory: 516608kb
input:
50000 99997 1 2 92917899 2 3 90125226 3 4 10806409 4 5 56452040 5 6 34960749 6 7 14085023 7 8 96350028 8 9 49181182 9 10 70920046 10 11 3727766 11 12 42039112 12 13 63921049 13 14 7634090 14 15 24597384 15 16 13087802 16 17 63136838 17 18 58806049 18 19 98769520 19 20 943620 20 21 70246129 21 22 145...
output:
53806372 101314854 124850165 38514625 96220435 122794730 84721400 112668433 107849606 160932332 116266392 101162529 140732651 93988737 87814230 71121316 72361729 54614389 95539309 119384111 95776872 109513557 60646451 142757728 61377855 40164780 49674827 71836734 15251469 135919057 66944724 83240312...
result:
ok 1000000 numbers
Test #12:
score: 0
Accepted
time: 842ms
memory: 636792kb
input:
47254 94505 1 2 66784117 2 3 20692517 3 4 98907287 4 5 41209476 5 6 7315104 6 7 98282771 7 8 64009902 8 9 85598965 9 10 9106474 10 11 43526655 11 12 86178462 12 13 61614372 13 14 27069126 14 15 79504944 15 16 86618089 16 17 67501242 17 18 46707561 18 19 78208083 19 20 17517466 20 21 71088132 21 22 4...
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 1000000 numbers
Test #13:
score: 0
Accepted
time: 614ms
memory: 514916kb
input:
50000 99997 1 2 98934090 2 3 49958895 3 4 58253925 4 5 86958288 5 6 70023844 6 7 4574778 7 8 49968914 8 9 40118056 9 10 93722127 10 11 77674148 11 12 44589976 12 13 74650925 13 14 83434953 14 15 34825819 15 16 35073184 16 17 59460038 17 18 16371972 18 19 27840035 19 20 9921286 20 21 96569520 21 22 4...
output:
-1 -1 134038278 -1 83855508 -1 94630818 86426735 117282785 -1 -1 -1 109399438 -1 69917163 117201505 -1 213614655 73984801 66457361 130458925 -1 146183017 -1 -1 103976773 -1 140048318 -1 62379190 110100909 -1 -1 251950582 130937281 269193796 195833904 65545467 41245573 174339106 35843841 -1 225365426...
result:
ok 1000000 numbers
Test #14:
score: 0
Accepted
time: 874ms
memory: 640376kb
input:
50000 99997 1 2 17375119 2 3 31851662 3 4 8170046 4 5 23402169 5 6 16593634 6 7 67608438 7 8 2152560 8 9 39976586 9 10 69360624 10 11 65763420 11 12 79851569 12 13 83366479 13 14 73247163 14 15 79617102 15 16 51422981 16 17 8247209 17 18 53533672 18 19 5835039 19 20 9087828 20 21 78361404 21 22 1259...
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 1000000 numbers
Test #15:
score: 0
Accepted
time: 571ms
memory: 513960kb
input:
50000 99997 1 2 5365249 2 3 3680840 3 4 78159884 4 5 47955436 5 6 79818314 6 7 28290681 7 8 40921438 8 9 24688692 9 10 51624528 10 11 91390229 11 12 85086584 12 13 54065610 13 14 63418526 14 15 68141823 15 16 34254175 16 17 40363485 17 18 25950162 18 19 72245968 19 20 33162092 20 21 66673294 21 22 9...
output:
-1 -1 -1 134550531 -1 -1 -1 -1 -1 120627184 -1 -1 61901139 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 124447122 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 166056372 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 211256959 -1 -1 -1 -1 -...
result:
ok 1000000 numbers
Test #16:
score: 0
Accepted
time: 668ms
memory: 514772kb
input:
50000 99997 1 2 35057961 2 3 18981482 3 4 95632037 4 5 86885314 5 6 25182878 6 7 72699727 7 8 20208774 8 9 59268387 9 10 95119664 10 11 62893530 11 12 48832042 12 13 68165768 13 14 40252493 14 15 62587376 15 16 36404114 16 17 93940727 17 18 73595432 18 19 16433752 19 20 63341507 20 21 10402200 21 22...
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 1000000 numbers
Test #17:
score: 0
Accepted
time: 812ms
memory: 646332kb
input:
50000 99997 1 2 46544767 2 3 8243609 3 4 5601548 4 5 60479579 5 6 14824151 6 7 28422743 7 8 88933456 8 9 60953889 9 10 20751441 10 11 39806723 11 12 38344448 12 13 53972218 13 14 89573878 14 15 28259842 15 16 37315745 16 17 16482195 17 18 64455654 18 19 15699308 19 20 9371659 20 21 1596047 21 22 313...
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 1000000 numbers
Test #18:
score: 0
Accepted
time: 2499ms
memory: 1008080kb
input:
300000 524957 271965 75040 3707206 274807 129357 30958435 117116 83872 16523219 226906 176337 54622289 292180 129339 99517106 108353 68942 43859480 54225 298731 62385795 150951 54672 53188105 261944 206344 44581560 178510 222455 29849439 283315 31967 86418219 81867 95292 78675143 286216 196835 73299...
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 1000000 numbers
Test #19:
score: -100
Memory Limit Exceeded
input:
300000 657723 161802 55990 96498214 248178 5906 52198569 139131 242589 66337226 65957 96980 34478261 31925 39409 37403752 235637 201318 97690264 158188 56254 33799900 155108 271456 76855577 102838 168675 95897185 274694 291785 8110654 75921 138401 57787947 60050 46287 4138252 265123 65590 4089049 15...
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 ...