Submission details
Task:Wide delivery
Sender:aalto26fm_003
Submission time:2026-10-05 17:02:06 +0300
Language:C++ (C++20)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#13ACCEPTED0.00 sdetails
#14ACCEPTED0.00 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#19ACCEPTED0.00 sdetails
#20ACCEPTED0.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.00 sdetails
#27ACCEPTED0.00 sdetails
#28ACCEPTED0.00 sdetails
#29ACCEPTED0.00 sdetails
#30ACCEPTED0.00 sdetails
#31ACCEPTED0.00 sdetails
#32ACCEPTED0.01 sdetails
#33ACCEPTED0.00 sdetails
#34ACCEPTED0.01 sdetails
#35ACCEPTED0.00 sdetails
#36ACCEPTED0.01 sdetails
#37ACCEPTED0.00 sdetails
#38ACCEPTED0.01 sdetails
#39ACCEPTED0.00 sdetails
#40ACCEPTED0.01 sdetails
#41ACCEPTED0.01 sdetails
#42ACCEPTED0.01 sdetails
#43ACCEPTED0.01 sdetails
#44ACCEPTED0.01 sdetails
#45ACCEPTED0.01 sdetails
#46ACCEPTED0.01 sdetails
#47ACCEPTED0.00 sdetails
#48ACCEPTED0.01 sdetails
#49ACCEPTED0.00 sdetails
#50ACCEPTED0.01 sdetails
#51ACCEPTED0.01 sdetails
#52ACCEPTED0.01 sdetails
#53ACCEPTED0.01 sdetails
#54ACCEPTED0.01 sdetails
#55ACCEPTED0.01 sdetails
#56ACCEPTED0.01 sdetails
#57ACCEPTED0.01 sdetails
#58ACCEPTED0.01 sdetails
#59ACCEPTED0.01 sdetails
#60ACCEPTED0.30 sdetails
#61ACCEPTED0.27 sdetails
#62ACCEPTED0.28 sdetails
#63ACCEPTED0.30 sdetails
#64ACCEPTED0.37 sdetails
#65ACCEPTED0.24 sdetails
#66ACCEPTED0.36 sdetails
#67ACCEPTED0.21 sdetails
#68ACCEPTED0.36 sdetails
#69ACCEPTED0.19 sdetails

Code

#include <iostream>
#include <vector>
#include <functional>
#include <set>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <limits>
#include <queue>

typedef long long Int;

std::tuple<Int> readInt1(){
    Int a;
    std::cin >> a;
    return {a};
}
std::tuple<Int,Int> readInt2(){
    Int a, b;
    std::cin >> a >> b;
    return {a,b};
}
std::tuple<Int,Int,Int> readInt3(){
    Int a, b, c;
    std::cin >> a >> b >> c;
    return {a,b,c};
}

std::vector<Int> readVecInt(Int n){
    std::vector<Int> arr(n);
    for (Int i = 0; i < n; i++){
        Int a;
        std::cin >> a;
        arr[i] = a;
    }
    return arr;
}
std::vector<std::string> readVecStr(Int n){
    std::vector<std::string> arr(n);
    for (Int i = 0; i < n; i++){
        std::string a;
        std::cin >> a;
        arr[i] = a;
    }
    return arr;
}

std::vector<long long> readVecLong(Int n){
    std::vector<long long> arr(n);
    for (Int i = 0; i < n; i++){
        long long a;
        std::cin >> a;
        arr[i] = a;
    }
    return arr;
}

std::vector<std::tuple<Int,Int>> readVecTup2(Int n){
    std::vector<std::tuple<Int,Int>> arr(n);
    for (Int i = 0; i < n; i++){
        Int a, b;
        std::cin >> a;
        std::cin >> b;
        arr[i] = {a,b};
    }
    return arr;
}

std::vector<std::tuple<Int,Int,Int>> readVecTup3(Int n){
    std::vector<std::tuple<Int,Int,Int>> arr(n);
    for (Int i = 0; i < n; i++){
        Int a, b, c;
        std::cin >> a;
        std::cin >> b;
        std::cin >> c;
        arr[i] = {a,b,c};
    }
    return arr;
}
std::vector<std::tuple<Int,Int,Int,Int>> readVecTup4(Int n){
    std::vector<std::tuple<Int,Int,Int,Int>> arr(n);
    for (Int i = 0; i < n; i++){
        Int a, b, c,d;
        std::cin >> a;
        std::cin >> b;
        std::cin >> c;
        std::cin >> d;
        arr[i] = {a,b,c,d};
    }
    return arr;
}

void printNewLine(){std::cout << "\n";}
template<typename T, typename... Ts>
std::tuple<Ts...> tail(std::tuple<T,Ts...> as){
    return std::apply([](T &a, Ts... b){return std::make_tuple(b...);},as);
}

template<typename T>
void print(T a){std::cout << std::setprecision(19) << a;}
template<typename... T>
void println(T... a);

template<typename T, typename Ts>
void print(std::tuple<T,Ts> a){
    print(std::get<0>(a));
    print(" ");
    print(std::get<1>(a));
}

template<typename T, typename... Ts>
void print(std::tuple<T,Ts...> a){
    print(std::get<0>(a));
    print(" ");
    print(tail(a));
}

template<typename T>
void print(const std::vector<T> &arr, Int width = -1){
    if (width == -1) width = arr.size();
    for (Int i = 0; i < (Int)arr.size(); i++){
        print(arr[i]);
        if (i+1 == (Int)arr.size()) continue;
        if ((i%width) == width-1) printNewLine();
        if ((i%width) != width-1) print(" ");
    }    
}
template<typename... T>
void println(T... a){print(a...);printNewLine();}



template<typename T>
void sorted(std::vector<T> &arr){
    std::sort(arr.begin(),arr.end(),[](const T &a, const T &b){ return a < b; });
}


template<typename T>
std::set<T> toSet(const std::vector<T> &vec){
    std::set<T> c;
    for (T a : vec){ c.emplace(a);}
    return c;
}

template<typename T, typename N>
std::vector<N> map(const std::vector<T> &a, const std::function<N(T)> &transform){
    std::vector<N> b(a.size());
    Int i = 0;
    for (T x : a){
        b[i] = transform(x);
        i++;
    }
    return b;
}

template<typename N, typename M, typename R>
std::vector<R> zip(const std::vector<N> &a, const  std::vector<M> &b, const std::function<R(N,M)> &transform){
    Int n = std::min(a.size(),b.size());
    std::vector<R> res(n);
    for (Int i = 0; i < n; i++){
        res[i] = transform(a[i],b[i]);
    }
    return res;
}

template<typename T, typename N>
std::vector<N> convertVec(const std::vector<T> &a){
    std::vector<N> b(a.size());
    Int i = 0;
    for (T x : a){
        b[i] = x;
        i++;
    }
    return b;
}
template<typename T>
std::vector<T> reverse(const std::vector<T> &a){
    std::vector<T> b(a.size());
    Int i = 0;
    for (T x : a){
        b[a.size()-1-i] = x;
        i++;
    }
    return b;
}



template<typename T, typename R>
R reduce(const std::vector<T> &arr, R init, const std::function<R(const R,const T)> &transform){
    R current = init;
    for (Int idx = 0; idx < (Int)arr.size(); idx++){
        current = transform(current,arr[idx]);
    };
    return current;
}
template<typename T>
T max(const std::vector<T> &arr){return reduce(arr, arr[0], static_cast<std::function<T(const T,const T)>>(static_cast<const T& (*)(const T&, const T&)>(std::max<T>)));}
template<typename T>
T min(const std::vector<T> &arr){return reduce(arr, arr[0], static_cast<std::function<T(const T,const T)>>(static_cast<const T& (*)(const T&, const T&)>(std::min<T>)));}

template<typename T>
std::function<T(const T,const T)> add(){return [](T a,T b){return a+b;};}
template<typename T>
std::function<T(const T,const T)> modAdd(T mod){return [mod](T a,T b){return (((a+b)%mod)+mod)%mod;};}
template<typename T, typename R>
std::function<R(const R,const T)> mulAdd(R mul){return [mul](R a,T b){return a+b*mul;};}
template<typename T>
T sum(const std::vector<T> &arr){return reduce(arr, 0, add<T>());}
template<typename T>
T avg(const std::vector<T> &arr){return reduce(arr, 0.0, mulAdd<double,T>(1.0/arr.size()));}

template<typename T>
T binarySearch(T min, T max, const std::function<bool(T)> &leq){
    if (min == max) return max;
    T guess = (min+max)/2;
    if (leq(guess)){
        return binarySearch(min,guess,leq);
    }else{
        return binarySearch(guess+1,max,leq);
    }
}

template<typename T>
T binarySearchDecending(T min, T max, const std::function<bool(T)> &leq){
    std::function<bool(T)> gt = [leq](T x){
        return !leq(x);
    };
    return binarySearch(min,max+1, gt)-1;
}

template<typename T>
std::vector<T> cloneVec(std::vector<T> a){return a;}

template<typename T>
std::vector<T> padding(const std::vector<T> &initial, T num, Int start, Int end){
    std::vector<T> arr(start+initial.size()+end);
    for (Int i = 0; i < start; i++){
        arr[i] = num;
    }
    for (Int i = 0; i < (Int)initial.size(); i++){
        arr[start+i] = initial[i];
    }
    for (Int i = 0; i < end; i++){
        arr[start+initial.size()+i] = num;
    }
    return arr;
}

template<typename T>
Int findMax(Int start, Int end, const std::function<T(Int)> &maxHeuristic){
    T initialGuess = maxHeuristic(start);
    Int index = start;
    for (Int i = start; i <= end; i++){
        if (initialGuess < maxHeuristic(i)){
            initialGuess = maxHeuristic(i);
            index = i;
        }
    }
    return index;
}

template<typename T>
void operateOnMax(Int start, Int end, const std::function<T(Int)> &maxHeuristic, const std::function<void(Int)> &found){
    found(findMax(start,end,maxHeuristic));
}

template<typename T>
void stackOperate(std::vector<T> init, const std::function<std::vector<T>(T)> operate){
    std::stack<T> stack;
    for (auto x : init){
        stack.push(x);
    }
    while (!stack.empty()){
        T next = stack.top();
        stack.pop();
        std::vector<T> nextSteps = operate(next);
        for (T a : nextSteps){
            stack.push(a);
        }
    }
}

template<typename T>
void queueOperate(std::vector<T> init, const std::function<std::vector<T>(T)> operate){
    std::queue<T> que;
    for (auto x : init){
        que.push(x);
    }
    while (!que.empty()){
        T next = que.front();
        que.pop();
        std::vector<T> nextSteps = operate(next);
        for (T a : nextSteps){
            que.push(a);
        }
    }
}

template<typename T>
void priorityQueueOperate(std::vector<T> init, const std::function<std::vector<T>(T)> operate){
    std::priority_queue<T> que;
    for (auto x : init){
        que.push(x);
    }
    while (!que.empty()){
        T next = que.top();
        que.pop();
        std::vector<T> nextSteps = operate(next);
        for (T a : nextSteps){
            que.push(a);
        }
    }
}

template<typename T>
void recursiveVectorSplit(Int start, Int end, Int distl, Int distr, const std::function<T(Int)> &maxHeuristic, const std::function<void(Int)> &found){
    if (start == end){
        return found(start);
    }else if (end < start){
        return;
    }
    std::tuple<Int,Int> range = {start,end};
    std::function<std::vector<std::tuple<Int,Int>>(std::tuple<Int,Int>)> splitter = [distl, distr,&maxHeuristic,&found](std::tuple<Int,Int> range){
        auto [start,end] = range;
        Int idx = findMax(start, end, maxHeuristic);
        found(idx);
        std::vector<std::tuple<Int,Int>> next;
        if (idx+distl+1 <= end){
            next.push_back({idx+distl+1,end});
        }
        if (start <= idx-distr-1){
            next.push_back({start, idx-distr-1});
        }
        return next;
    };
    stackOperate({range},splitter);
}


template<typename T>
std::vector<T> dynamicallyComputableList(Int n, std::function<T(std::vector<T>&,Int)> next){
    std::vector<T> arr(n);
    for (Int i = 0; i < n; i++){
        arr[i] = next(arr,i);
    }
    return arr;
}
template<typename T>
Int indexOfBinarySearch(const std::vector<T> &arr, const T &find){
    return binarySearch((Int)0,(Int)arr.size()-1,(std::function<bool(Int)>)[&arr, &find](Int guess){return find <= arr[guess];});
}

template<typename T>
std::unordered_map<T, Int> indexCompress(const std::vector<T> &arr){
    std::unordered_map<T, Int> compressed;
    Int i = 0;
    for (T x : arr){
        if (compressed.find(x) != compressed.end()) compressed[x] = i++;
    }
    return compressed;
}   

template<typename... Ts>
std::tuple<std::vector<std::tuple<Int,Ts...>>, std::vector<Int>> edgeIndexing(int n, std::vector<std::tuple<Int,Ts...>> edges){
    sorted(edges);
    std::vector<Int> edgeIndex(n+1);
    {
        Int j = 0;
        for (Int i = 0; i < (Int)edges.size(); i++) {
            auto a = std::get<0>(edges[i]);
            while (j <= a){
                edgeIndex[j++] = i;
            }
        }
        while (j < n){
            edgeIndex[j++] = edges.size();
        }
        edgeIndex[n] = edges.size(); 
    }
    return {edges,edgeIndex};
}


template<typename T>
std::tuple<std::vector<T>, std::vector<Int>> shortestPathDirected(const Int n, std::vector<std::tuple<Int, Int, T>> &edges, Int start){
    //assumes all paths are between 0 <= c < n
    //assumes 0 indexing
    std::vector<Int> path(n);
    std::vector<bool> edgeUpdated(n);
    std::vector<T> distance(n);
    for (Int i = 0; i < n; i++) path[i] = i;
    for (Int i = 0; i < n; i++) edgeUpdated[i] = true;
    edgeUpdated[start] = false;
    for (Int i = 0; i < n; i++) distance[i] = (T)0; //std::numeric_limits<T>::max()/4;
    distance[start] = std::numeric_limits<T>::max(); //0;
    sorted(edges);
    std::vector<Int> edgeIndex(n+1);
    {
        Int j = 0;
        for (Int i = 0; i < (Int)edges.size(); i++) {
            auto& [a,b,w] = edges[i];
            while (j <= a){
                edgeIndex[j++] = i;
            }
        }
        while (j < n){
            edgeIndex[j++] = edges.size();
        }
        edgeIndex[n] = edges.size(); 
    }
    std::function<std::vector<std::tuple<Int,Int>>(std::tuple<Int,Int>)> func = [&distance,&edgeIndex,&edges,&path,&edgeUpdated](std::tuple<Int,Int> propagateW){
        auto& [weight,propagate] = propagateW;
        std::vector<std::tuple<Int,Int>> next;
        //if (distance[propagate] != -weight) return next;
        if (edgeUpdated[propagate]) return next;
        for (Int i = edgeIndex[propagate]; i < edgeIndex[propagate+1]; i++){
            auto& [a, b, w] = edges[i];
            //if (distance[a]+w < distance[b]){
            if (std::min(distance[a],w) > distance[b]){
                //next.push_back({-(distance[a]+w),b});
                next.push_back({std::min(distance[a],w),b});
                distance[b] = std::min(distance[a],w);
                path[b] = a;
                edgeUpdated[b] = false;
            }
        }
        edgeUpdated[propagate] = true;
        return next;
    };
    priorityQueueOperate((std::vector<std::tuple<Int,Int>>){{0,start}},func);
    //for (Int i = 0; i < n; i++) {
    //    bool changed = false;
    //    for (auto& e : edges) {
    //        auto& [a, b, w] = e;
    //        if (!changed) {changed = (distance[b] != std::min(distance[b], distance[a]+w));}
    //        if (distance[a]+w < distance[b]){
    //            distance[b] = distance[a]+w;
    //            path[b] = a;
    //        }
    //    }
    //    if (!changed) break;
    //    if (changed && i == n){
    //        return std::tuple((std::vector<T>){},(std::vector<Int>){});
    //    }
    //}
    return std::tuple(distance,path);
}

std::vector<Int> pathFromPathMap(std::vector<Int> &map, Int goal){
    std::stack<Int> fullPath;
    fullPath.push(goal);
    while (map[fullPath.top()] != fullPath.top()){
        fullPath.push(map[fullPath.top()]);
    }
    std::vector<Int> p;
    while (!fullPath.empty()){
        p.push_back(fullPath.top());
        fullPath.pop();
    }
    return p;
}


template<typename T>
std::tuple<std::vector<T>, std::vector<Int>> shortestPath(const Int n, std::vector<std::tuple<Int, Int, T>> &edgesMessy, Int start){
    std::vector<std::tuple<Int, Int, T>> edges;
    for (auto e : edgesMessy){
        auto [a,b,t] = e;
        edges.push_back({a,b,t});
        edges.push_back({b,a,t});
    }
    return shortestPathDirected(n, edges, start);
}



template<typename T>
std::vector<T> distanceTable(const std::vector<T> &init, const  std::function<T(T,T)> &distance){
    Int n = init.size();
    std::vector<T> table(n*n);
    for (Int i = 0; i < n; i++){
        table[i+n*i] = init[i];
        for (Int j = i-1; j >= 0; j--){
            table[j+n*i] = distance(init[j],table[j+1+n*i]);
        }
        for (Int j = i+1; j < n; j++){
            table[j+n*i] = distance(table[j-1+n*i],init[j]);
        }
    }
    return table;
}

void particles(){
    auto [n] = readInt1();
    auto arr = readVecLong(n);
    std::vector<long long> table = distanceTable(arr,add<long long>());
    print(table,n);
    //println(cost[n*n-1]);
}
template<typename T>
std::vector<T> range(const std::vector<T> &a, Int from, Int to){
    std::vector<T> b;
    for (Int i = from; i < to; i++){
        b.push_back(a[i]);
    }
    return b;
}

template<typename T>
bool forall(const std::vector<T> &a, std::function<bool(T)> &test){
    bool res = true;
    for (auto v : a){
        res = res & test(v);
    }
    return res;
}

int main() {
    auto [n,m] = readInt2();
    auto arr   = readVecTup3(m);
    auto [cost,path] = shortestPath((Int)(n+1),arr,(Int)1);
    for (int i = 2; i <=n; i++){
        print(cost[i]);
        print(" ");
    }
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
2 1
1 2 10

correct output
10 

user output
10 

Test 2

Verdict: ACCEPTED

input
3 2
1 3 2
2 3 3

correct output
2 2 

user output
2 2 

Test 3

Verdict: ACCEPTED

input
3 2
1 2 7
2 3 9

correct output
7 7 

user output
7 7 

Test 4

Verdict: ACCEPTED

input
3 2
1 2 7
1 3 5

correct output
7 5 

user output
7 5 

Test 5

Verdict: ACCEPTED

input
3 2
1 3 5
2 3 1

correct output
1 5 

user output
1 5 

Test 6

Verdict: ACCEPTED

input
4 5
1 2 6
1 3 6
1 4 7
2 3 7
...

correct output
6 6 7 

user output
6 6 7 

Test 7

Verdict: ACCEPTED

input
4 6
1 2 10
1 3 2
1 4 4
2 3 4
...

correct output
10 4 7 

user output
10 4 7 

Test 8

Verdict: ACCEPTED

input
4 5
1 2 5
1 3 1
2 3 3
2 4 2
...

correct output
5 3 3 

user output
5 3 3 

Test 9

Verdict: ACCEPTED

input
4 5
1 2 5
1 3 1
2 3 3
2 4 2
...

correct output
5 3 3 

user output
5 3 3 

Test 10

Verdict: ACCEPTED

input
5 8
1 2 1
1 5 7
2 3 1
2 4 4
...

correct output
7 7 7 7 

user output
7 7 7 7 

Test 11

Verdict: ACCEPTED

input
5 10
1 2 9
1 3 8
1 4 10
1 5 9
...

correct output
9 9 10 9 

user output
9 9 10 9 

Test 12

Verdict: ACCEPTED

input
5 5
1 2 5
1 3 5
2 5 5
3 5 4
...

correct output
5 5 4 5 

user output
5 5 4 5 

Test 13

Verdict: ACCEPTED

input
5 4
1 5 3
2 4 2
2 5 6
3 4 6

correct output
3 2 2 3 

user output
3 2 2 3 

Test 14

Verdict: ACCEPTED

input
5 10
1 2 2
1 3 1
1 4 2
1 5 3
...

correct output
3 3 3 3 

user output
3 3 3 3 

Test 15

Verdict: ACCEPTED

input
5 4
1 5 3
2 4 4
3 4 10
3 5 10

correct output
3 3 3 3 

user output
3 3 3 3 

Test 16

Verdict: ACCEPTED

input
5 10
1 2 8
1 3 2
1 4 9
1 5 4
...

correct output
8 8 9 8 

user output
8 8 9 8 

Test 17

Verdict: ACCEPTED

input
5 5
1 5 8
2 3 5
2 5 10
3 4 4
...

correct output
8 6 4 8 

user output
8 6 4 8 

Test 18

Verdict: ACCEPTED

input
5 4
1 3 9
1 5 4
2 3 6
2 4 9

correct output
6 9 6 4 

user output
6 9 6 4 

Test 19

Verdict: ACCEPTED

input
5 6
1 2 2
1 3 4
1 4 9
2 3 4
...

correct output
4 8 9 4 

user output
4 8 9 4 

Test 20

Verdict: ACCEPTED

input
10 30
1 2 2
1 4 7
1 7 3
1 9 7
...

correct output
7 7 7 7 7 7 7 7 7 

user output
7 7 7 7 7 7 7 7 7 

Test 21

Verdict: ACCEPTED

input
10 45
1 2 1
1 3 10
1 4 10
1 5 5
...

correct output
9 10 10 8 9 9 9 9 9 

user output
9 10 10 8 9 9 9 9 9 

Test 22

Verdict: ACCEPTED

input
10 15
1 2 6
1 5 5
2 3 5
2 6 9
...

correct output
6 5 1 5 6 5 2 5 1 

user output
6 5 1 5 6 5 2 5 1 

Test 23

Verdict: ACCEPTED

input
10 11
1 2 1
1 8 2
2 4 1
3 6 3
...

correct output
1 1 1 1 1 1 2 1 1 

user output
1 1 1 1 1 1 2 1 1 

Test 24

Verdict: ACCEPTED

input
10 42
1 2 10
1 3 10
1 4 10
1 5 2
...

correct output
10 10 10 9 10 10 10 8 10 

user output
10 10 10 9 10 10 10 8 10 

Test 25

Verdict: ACCEPTED

input
10 11
1 3 4
1 7 6
1 8 5
2 8 3
...

correct output
3 4 5 3 3 6 5 6 3 

user output
3 4 5 3 3 6 5 6 3 

Test 26

Verdict: ACCEPTED

input
10 44
1 2 7
1 3 8
1 4 9
1 5 10
...

correct output
9 8 9 10 9 9 9 9 9 

user output
9 8 9 10 9 9 9 9 9 

Test 27

Verdict: ACCEPTED

input
10 17
1 3 8
1 4 7
1 5 3
1 10 10
...

correct output
6 8 7 7 7 8 6 4 10 

user output
6 8 7 7 7 8 6 4 10 

Test 28

Verdict: ACCEPTED

input
10 9
1 7 9
1 9 3
2 3 5
2 7 1
...

correct output
1 1 3 3 3 9 3 3 3 

user output
1 1 3 3 3 9 3 3 3 

Test 29

Verdict: ACCEPTED

input
10 22
1 2 7
1 3 5
1 5 8
1 7 10
...

correct output
9 9 9 9 10 10 9 9 10 

user output
9 9 9 9 10 10 9 9 10 

Test 30

Verdict: ACCEPTED

input
100 319
1 37 596623826
1 67 998074506
1 68 9921450
1 71 719317411
...

correct output
809139202 779101021 809139202 ...

user output
809139202 779101021 809139202 ...

Test 31

Verdict: ACCEPTED

input
100 266
1 23 218517540
1 24 983124839
1 31 8592846
1 89 688876470
...

correct output
847611626 667780838 619621653 ...

user output
847611626 667780838 619621653 ...

Test 32

Verdict: ACCEPTED

input
100 274
1 16 840345805
1 19 904448220
1 38 716537090
1 48 994458105
...

correct output
689140135 768509869 779139365 ...

user output
689140135 768509869 779139365 ...

Test 33

Verdict: ACCEPTED

input
100 320
1 2 662868746
1 13 500034126
1 18 920268074
1 28 358826234
...

correct output
718105196 718105196 718105196 ...

user output
718105196 718105196 718105196 ...

Test 34

Verdict: ACCEPTED

input
100 487
1 6 372811120
1 12 326784229
1 62 767189702
1 63 813226706
...

correct output
827543856 832678805 832678805 ...

user output
827543856 832678805 832678805 ...

Test 35

Verdict: ACCEPTED

input
100 188
1 26 137494118
1 37 131337951
1 41 826708914
1 70 649947068
...

correct output
649947068 640735040 649947068 ...

user output
649947068 640735040 649947068 ...

Test 36

Verdict: ACCEPTED

input
100 457
1 7 326353330
1 14 910706862
1 16 631528656
1 22 681300057
...

correct output
820829965 702130526 896049001 ...

user output
820829965 702130526 896049001 ...

Test 37

Verdict: ACCEPTED

input
100 129
1 38 471910939
1 41 761706427
1 78 839382115
2 3 563011796
...

correct output
507939807 507939807 507939807 ...

user output
507939807 507939807 507939807 ...

Test 38

Verdict: ACCEPTED

input
100 450
1 12 923504277
1 26 536204827
1 34 975212858
1 40 448475892
...

correct output
875938306 871669886 869664776 ...

user output
875938306 871669886 869664776 ...

Test 39

Verdict: ACCEPTED

input
100 103
1 56 527185407
1 74 697438766
2 31 224913296
2 54 924311238
...

correct output
37347058 37347058 8745675 3734...

user output
37347058 37347058 8745675 3734...

Test 40

Verdict: ACCEPTED

input
200 639
1 68 550240781
1 74 374173245
1 117 548283610
1 128 794673670
...

correct output
717510768 717510768 717510768 ...

user output
717510768 717510768 717510768 ...

Test 41

Verdict: ACCEPTED

input
200 533
1 61 325205605
1 65 319257144
1 116 525067592
1 124 29641733
...

correct output
637193247 637193247 637193247 ...

user output
637193247 637193247 637193247 ...

Test 42

Verdict: ACCEPTED

input
200 548
1 19 327701857
1 111 865795841
1 124 520305720
1 126 36803011
...

correct output
614189792 727936226 716643678 ...

user output
614189792 727936226 716643678 ...

Test 43

Verdict: ACCEPTED

input
200 640
1 3 435247294
1 56 85483517
1 67 895163010
1 117 900338510
...

correct output
766582321 702388421 749350380 ...

user output
766582321 702388421 749350380 ...

Test 44

Verdict: ACCEPTED

input
200 974
1 12 787274018
1 24 668226402
1 37 916647978
1 60 654136658
...

correct output
766542739 853023687 809142552 ...

user output
766542739 853023687 809142552 ...

Test 45

Verdict: ACCEPTED

input
200 377
1 75 609995697
1 133 644237757
1 159 703362524
2 86 532732048
...

correct output
532732048 613334611 703362524 ...

user output
532732048 613334611 703362524 ...

Test 46

Verdict: ACCEPTED

input
200 915
1 41 304105798
1 43 990074041
1 44 323946311
1 82 686995848
...

correct output
878680360 818270725 878680360 ...

user output
878680360 818270725 878680360 ...

Test 47

Verdict: ACCEPTED

input
200 260
1 50 433414357
1 82 889544848
1 146 629986792
2 3 199714786
...

correct output
260814459 247423049 458545197 ...

user output
260814459 247423049 458545197 ...

Test 48

Verdict: ACCEPTED

input
200 899
1 12 792915326
1 30 38447351
1 52 548163329
1 58 605992493
...

correct output
839528481 701642263 839528481 ...

user output
839528481 701642263 839528481 ...

Test 49

Verdict: ACCEPTED

input
200 207
1 139 75253797
1 186 378941690
2 31 682441131
2 193 520226255
...

correct output
76471569 76471569 24553207 245...

user output
76471569 76471569 24553207 245...

Test 50

Verdict: ACCEPTED

input
1000 3195
1 31 992737593
1 101 443344367
1 145 880813289
1 218 632539546
...

correct output
708044511 801259894 665475214 ...

user output
708044511 801259894 665475214 ...

Test 51

Verdict: ACCEPTED

input
1000 2667
1 142 559482382
1 290 288767892
1 303 701355423
1 523 235314604
...

correct output
665661624 483591462 665661624 ...

user output
665661624 483591462 665661624 ...

Test 52

Verdict: ACCEPTED

input
1000 2743
1 13 406970444
1 265 434163074
1 507 790586661
1 543 122643984
...

correct output
601182566 390173081 730820742 ...

user output
601182566 390173081 730820742 ...

Test 53

Verdict: ACCEPTED

input
1000 3203
1 48 328382050
1 262 604204040
1 408 103365525
1 418 456341860
...

correct output
604204040 604204040 604204040 ...

user output
604204040 604204040 604204040 ...

Test 54

Verdict: ACCEPTED

input
1000 4869
1 98 54871649
1 209 884297355
1 419 142420586
1 517 947321320
...

correct output
563349106 845725704 796515650 ...

user output
563349106 845725704 796515650 ...

Test 55

Verdict: ACCEPTED

input
1000 1887
1 201 609895505
1 614 994564074
2 92 165705474
2 711 453568020
...

correct output
453568020 559219929 559219929 ...

user output
453568020 559219929 559219929 ...

Test 56

Verdict: ACCEPTED

input
1000 4572
1 46 405238648
1 162 702406672
1 511 821029191
1 534 389746325
...

correct output
798643164 798643164 798643164 ...

user output
798643164 798643164 798643164 ...

Test 57

Verdict: ACCEPTED

input
1000 1304
1 270 132981930
1 275 840378812
1 608 292432241
2 213 71100983
...

correct output
221855990 272712489 411330140 ...

user output
221855990 272712489 411330140 ...

Test 58

Verdict: ACCEPTED

input
1000 4494
1 2 512116733
1 33 536320623
1 133 974053720
1 148 283425443
...

correct output
652786316 858166875 858166875 ...

user output
652786316 858166875 858166875 ...

Test 59

Verdict: ACCEPTED

input
1000 1040
1 757 59516440
1 965 648284414
2 629 401122994
2 710 908626707
...

correct output
22302054 22302054 22302054 223...

user output
22302054 22302054 22302054 223...

Test 60

Verdict: ACCEPTED

input
100000 154882
1 33511 978867794
1 62596 904646466
1 95787 49335302
2 5482 670103920
...

correct output
443566431 443566431 233851994 ...

user output
443566431 443566431 233851994 ...

Test 61

Verdict: ACCEPTED

input
100000 141702
1 2516 205209909
1 57052 401636362
2 40643 139232145
2 61512 543549089
...

correct output
139232145 205209909 205209909 ...

user output
139232145 205209909 205209909 ...

Test 62

Verdict: ACCEPTED

input
100000 143600
1 10252 585278633
1 27842 719546578
1 32959 489910952
1 99072 899597141
...

correct output
499599525 499599525 499599525 ...

user output
499599525 499599525 499599525 ...

Test 63

Verdict: ACCEPTED

input
100000 155080
1 18730 347172856
1 62992 566295906
1 88597 621768522
2 45171 787774115
...

correct output
564607240 367457395 227107693 ...

user output
564607240 367457395 227107693 ...

Test 64

Verdict: ACCEPTED

input
100000 196705
1 17467 687033132
1 24019 674209470
1 37432 745030271
1 43793 812959110
...

correct output
696430342 515151655 701369436 ...

user output
696430342 515151655 701369436 ...

Test 65

Verdict: ACCEPTED

input
100000 122199
1 55264 348027668
1 97680 952735621
2 24158 324882355
2 58809 663110970
...

correct output
249264997 155608338 397132612 ...

user output
249264997 155608338 397132612 ...

Test 66

Verdict: ACCEPTED

input
100000 189288
1 13135 578257724
1 26546 844229453
1 98245 997403805
2 8642 862417615
...

correct output
626438651 487556033 633684516 ...

user output
626438651 487556033 633684516 ...

Test 67

Verdict: ACCEPTED

input
100000 107630
1 56075 414317534
1 95761 53615582
2 16544 826029134
2 58165 246076722
...

correct output
53615582 53615582 53615582 536...

user output
53615582 53615582 53615582 536...

Test 68

Verdict: ACCEPTED

input
100000 187345
1 55230 772133163
1 72992 175103260
2 4680 820511816
2 60050 304027047
...

correct output
631015331 546315776 528478244 ...

user output
631015331 546315776 528478244 ...

Test 69

Verdict: ACCEPTED

input
100000 101036
1 31139 432550553
1 32626 97199921
2 59835 174305501
2 71346 929083000
...

correct output
2032871 2032871 2032871 203287...

user output
2032871 2032871 2032871 203287...