QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#473117#4741. PowódźStarrykiller100 ✓100ms23132kbC++233.9kb2024-07-11 21:57:542024-07-11 21:57:55

Judging History

你现在查看的是最新测评结果

  • [2024-07-11 21:57:55]
  • 评测
  • 测评结果:100
  • 用时:100ms
  • 内存:23132kb
  • [2024-07-11 21:57:54]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;


namespace sk {
    // modint: https://www.cnblogs.com/hzy1/p/16344746.html
    // Edited by Starrykiller.
    using i64=int64_t;
    using u64=unsigned i64;
    using i32=int32_t;
    i32 inverse(i32 a, i32 m) { i32 r=1;
        while (a>1) { i32 t=m/a; r=i64(r)*(m-t)%m; a=m-t*a; }
        return r;
    }
    template<i32 mod>
    struct static_modint { 
        i32 x;
        static_modint(i64 x) : x(normal(x%mod)) {}
        static_modint(i32 x, nullptr_t) : x(x) {}
        static_modint(): x(0) {}
        inline constexpr i32 normal(i32 x) { 
            if (x>=mod) x-=mod;
            return x+((x>>31)&mod); 
        }
        inline constexpr i32 val() const { return x; }
        inline constexpr explicit operator bool() const { return x; }
        inline constexpr static_modint inv() const { assert(x!=0); return static_modint(inverse(x,mod),nullptr); }
        inline constexpr static_modint pow(i64 x) const { assert(x>=0); static_modint a=*this, res=1;
            while (x) { if (x&1) res*=a; a*=a; x>>=1; } return res; }
        inline constexpr static_modint operator-() const { return static_modint(mod-x); }
        inline constexpr static_modint& operator+=(const static_modint &rhs) { x=normal(x+rhs.x); return *this; }
        inline constexpr static_modint& operator-=(const static_modint &rhs) { x=normal(x-rhs.x); return *this; }
        inline constexpr static_modint& operator++() { return (*this)+=1; }
        inline constexpr static_modint& operator--() { return (*this)-=1; }
        inline constexpr static_modint& operator*=(const static_modint &rhs) { x=i64(x)*rhs.x%mod; return *this; }
        inline constexpr static_modint& operator/=(const static_modint &rhs) { return *this *= rhs.inv(); }
        friend static_modint operator+(const static_modint &lhs, const static_modint &rhs) { auto res=lhs; res+=rhs; return res; }
        friend static_modint operator-(const static_modint &lhs, const static_modint &rhs) { auto res=lhs; res-=rhs; return res; }
        friend static_modint operator*(const static_modint &lhs, const static_modint &rhs) { auto res=lhs; res*=rhs; return res; }
        friend static_modint operator/(const static_modint &lhs, const static_modint &rhs) { auto res=lhs; res/=rhs; return res; }
        friend static_modint operator++(static_modint &x, int) { auto tmp=x; x+=1; return tmp; }
        friend static_modint operator--(static_modint &x, int) { auto tmp=x; x-=1; return tmp; }
        friend std::istream& operator>>(std::istream &is, static_modint &a) { i64 v; is >> v; a=static_modint(v%mod); return is; }
        friend std::ostream& operator<<(std::ostream &os, const static_modint &a) { os << a.val(); return os; }
        bool operator==(const static_modint& rhs) const { return x==rhs.x; }
        bool operator!=(const static_modint& rhs) const { return x!=rhs.x; }
    };
    using modint998244353=static_modint<998244353>;
    using modint1000000007=static_modint<1000000007>;
};

constexpr int MAXN=5e5+10; using ll=sk::modint1000000007;
int n, m, h;
int id(int x, int y) { return (x-1)*m+y; }
struct E { int u, v, w; }; vector<E> e;
int fa[MAXN], siz[MAXN], val[MAXN]; ll f[MAXN];
int get(int x) { return fa[x]==x?x:fa[x]=get(fa[x]); }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin>>n>>m>>h;
    for (int i=1; i<=n; ++i) for (int j=1,w; j<m; ++j)  
        cin>>w, e.push_back({id(i,j),id(i,j+1),w});
    for (int i=1; i<n; ++i) for (int j=1,w; j<=m; ++j)  
        cin>>w, e.push_back({id(i,j),id(i+1,j),w});
    sort(e.begin(),e.end(),[](const E& a, const E& b) { return a.w<b.w; });
    for (int i=1; i<=n*m; ++i) siz[fa[i]=i]=1, val[i]=-1; int cur=0;
    for (auto [u,v,w]: e) {
        u=get(u), v=get(v);
        if (u==v) continue;
        f[v]=(f[u]+w-val[u])*(f[v]+w-val[v]);
        fa[u]=v; siz[v]+=siz[u]; val[v]=w;
        cur=w;
    }
    ll ans=f[get(1)];
    ans+=h-cur;
    cout<<ans<<'\n';


}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 1ms
memory: 9964kb

input:

3 2 2
1
1
1
1 2
1 1

output:

65

result:

ok 1 number(s): "65"

Test #2:

score: 0
Accepted
time: 1ms
memory: 10096kb

input:

1 10 4
1 2 1 4 1 4 1 2 2

output:

8883

result:

ok 1 number(s): "8883"

Test #3:

score: 0
Accepted
time: 0ms
memory: 10020kb

input:

10 1 4
4
3
3
4
3
2
3
2
3

output:

520325

result:

ok 1 number(s): "520325"

Test #4:

score: 0
Accepted
time: 1ms
memory: 10208kb

input:

2 5 4
2 3 2 3
4 1 4 4
2 4 1 1 1

output:

7729

result:

ok 1 number(s): "7729"

Test #5:

score: 0
Accepted
time: 0ms
memory: 10196kb

input:

3 3 4
4 3
3 3
4 3
2 2 2
2 4 1

output:

17921

result:

ok 1 number(s): "17921"

Test #6:

score: 0
Accepted
time: 1ms
memory: 9820kb

input:

3 3 4
4 4
4 4
4 4
4 4 4
4 4 4

output:

1953125

result:

ok 1 number(s): "1953125"

Test #7:

score: 0
Accepted
time: 1ms
memory: 9552kb

input:

3 3 4
4 4
4 4
4 4
4 1 4
1 4 1

output:

42875

result:

ok 1 number(s): "42875"

Test #8:

score: 0
Accepted
time: 1ms
memory: 9976kb

input:

3 3 4
4 4
1 1
1 4
1 4 1
1 1 4

output:

3275

result:

ok 1 number(s): "3275"

Test #9:

score: 0
Accepted
time: 1ms
memory: 9444kb

input:

3 3 4
1 4
4 4
4 1
1 1 1
1 1 1

output:

515

result:

ok 1 number(s): "515"

Test #10:

score: 0
Accepted
time: 0ms
memory: 11012kb

input:

3 3 4
2 3
1 3
1 1
2 1 1
3 3 1

output:

953

result:

ok 1 number(s): "953"

Test #11:

score: 0
Accepted
time: 1ms
memory: 10512kb

input:

3 3 4
1 2
2 2
1 3
2 2 3
1 4 2

output:

3647

result:

ok 1 number(s): "3647"

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #12:

score: 20
Accepted
time: 0ms
memory: 9868kb

input:

20 50 1000000
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...

output:

170547121

result:

ok 1 number(s): "170547121"

Test #13:

score: 0
Accepted
time: 1ms
memory: 9868kb

input:

20 50 1000000000
10000046 10000067 10000092 10000047 10000084 10000028 10000023 10000074 10000049 10000063 10000089 10000065 10000049 10000047 10000023 10000040 10000083 10000064 10000045 10000019 10000084 10000093 10000034 10000080 10000065 10000039 10000085 10000029 10000052 10000001 10000074 1000...

output:

953602992

result:

ok 1 number(s): "953602992"

Test #14:

score: 0
Accepted
time: 2ms
memory: 11332kb

input:

20 50 1000000000
18631670 424283007 439843407 347131510 105575359 872921168 945764761 763130994 465896030 153905519 541741804 393795151 979905640 830133551 520704830 997519088 64792655 348110406 617681465 423518890 930074544 731784104 344914030 735361107 304445746 158645919 551514530 116387391 32473...

output:

329080003

result:

ok 1 number(s): "329080003"

Test #15:

score: 0
Accepted
time: 1ms
memory: 10480kb

input:

5 200 1000
881 81 335 253 542 849 8 294 165 714 520 794 83 524 715 148 908 474 152 679 857 286 84 156 182 735 340 328 473 234 44 113 807 529 927 179 994 462 894 227 970 912 96 599 568 460 538 142 576 737 269 450 824 389 973 607 745 274 92 685 273 273 236 488 600 950 488 228 185 100 391 476 134 8 289...

output:

369972116

result:

ok 1 number(s): "369972116"

Test #16:

score: 0
Accepted
time: 0ms
memory: 11164kb

input:

200 5 1000
807 817 476 957
393 692 7 749
533 61 924 211
478 887 969 597
524 801 913 845
282 66 904 655
486 290 337 200
934 615 519 707
697 173 503 823
812 631 982 255
497 770 790 88
102 155 149 595
90 90 49 458
56 958 561 821
450 619 999 948
299 897 856 810
102 461 395 690
478 382 11 754
396 306 426...

output:

946940256

result:

ok 1 number(s): "946940256"

Test #17:

score: 0
Accepted
time: 0ms
memory: 10724kb

input:

100 20 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10000...

output:

0

result:

ok 1 number(s): "0"

Test #18:

score: 0
Accepted
time: 2ms
memory: 11232kb

input:

30 50 1000000000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1000000000 1000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1000000000 1000000000 1 1 1 1 1 1 1000000000 1000000000 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1000000000 100000...

output:

892617320

result:

ok 1 number(s): "892617320"

Test #19:

score: 0
Accepted
time: 0ms
memory: 9844kb

input:

10 200 100
1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1...

output:

749218615

result:

ok 1 number(s): "749218615"

Test #20:

score: 0
Accepted
time: 0ms
memory: 10784kb

input:

40 40 100000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
1 1 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27...

output:

427808075

result:

ok 1 number(s): "427808075"

Test #21:

score: 0
Accepted
time: 1ms
memory: 10652kb

input:

1 2000 2000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

365900122

result:

ok 1 number(s): "365900122"

Test #22:

score: 0
Accepted
time: 1ms
memory: 10224kb

input:

1 2000 2000
1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1945 1944 1943 194...

output:

365900122

result:

ok 1 number(s): "365900122"

Test #23:

score: 0
Accepted
time: 1ms
memory: 9888kb

input:

2000 1 1000000000
398534875
116162463
486023833
619011736
802775073
140162758
491033298
609403043
164451190
531565587
590928679
808372598
896490035
728609092
739314764
394458434
970784327
67682173
100982258
501958061
213460980
640551256
458732338
359443653
19306582
116743879
809148348
16693732
67254...

output:

163302527

result:

ok 1 number(s): "163302527"

Test #24:

score: 0
Accepted
time: 1ms
memory: 10740kb

input:

1 1000 1000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

616547549

result:

ok 1 number(s): "616547549"

Subtask #3:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #25:

score: 20
Accepted
time: 7ms
memory: 12052kb

input:

200 500 5
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ...

output:

971459291

result:

ok 1 number(s): "971459291"

Test #26:

score: 0
Accepted
time: 28ms
memory: 15044kb

input:

445 445 5
3 5 4 5 2 1 3 2 5 3 3 4 2 2 1 1 4 5 4 5 4 4 5 1 3 1 1 4 4 1 1 5 4 5 3 3 5 2 1 2 2 5 4 2 2 2 2 4 2 2 4 3 3 2 5 4 1 5 1 1 3 1 4 1 4 3 3 3 4 1 3 4 5 5 2 1 1 5 5 4 5 3 3 2 2 3 4 5 2 5 4 2 3 1 3 3 4 3 3 1 3 2 3 4 3 5 3 1 5 3 1 5 4 4 1 4 2 4 3 5 1 1 3 3 5 5 1 5 4 5 2 4 4 4 3 4 2 4 2 4 1 5 4 5 2 ...

output:

290571952

result:

ok 1 number(s): "290571952"

Test #27:

score: 0
Accepted
time: 31ms
memory: 16268kb

input:

400 500 5
4 2 2 2 2 3 2 4 2 4 4 2 4 2 4 2 4 3 4 4 2 4 2 2 3 4 4 4 2 3 4 3 3 3 2 4 3 2 3 4 3 4 4 2 4 3 2 4 4 4 3 3 4 3 2 2 3 4 2 2 4 4 4 2 3 4 4 4 3 2 2 4 3 4 2 2 4 4 3 4 3 2 2 2 4 4 3 3 3 4 2 2 4 3 2 4 3 3 3 3 4 2 2 3 4 3 3 2 3 3 2 4 2 3 3 3 2 4 3 3 4 4 4 3 2 2 2 2 3 4 2 4 2 3 2 3 2 2 3 2 4 4 2 3 3 ...

output:

158748992

result:

ok 1 number(s): "158748992"

Test #28:

score: 0
Accepted
time: 3ms
memory: 11340kb

input:

100 100 5
1 5 5 5 5 1 5 5 5 5 5 5 5 5 5 5 5 1 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 1 5 5 5 5 5 5 5 5 5 5 5 1 5 5 5 5 5 5 5 5 5 5 5 5 1 5 5 1 5 5 5 1 5 5 5 5 5 5 1 5 5 5 5 5 1 5 5 5 5 5 5
5 5 5 1 5 5 1 1 5 5 5 1 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 1 5 5 5 5 5 5 5 1 5 5 5 5 5 ...

output:

629077254

result:

ok 1 number(s): "629077254"

Test #29:

score: 0
Accepted
time: 0ms
memory: 9932kb

input:

100 100 5
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 5 1 1 1 1 1 1 1 1 ...

output:

622773792

result:

ok 1 number(s): "622773792"

Test #30:

score: 0
Accepted
time: 7ms
memory: 12424kb

input:

20 5000 5
1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 5 1 ...

output:

607723524

result:

ok 1 number(s): "607723524"

Test #31:

score: 0
Accepted
time: 6ms
memory: 11348kb

input:

1 100000 5
1 1 3 2 2 4 3 3 4 5 3 1 3 3 5 2 4 5 3 2 5 3 3 1 5 5 4 4 1 3 2 3 1 4 5 5 3 3 5 5 4 2 2 3 2 1 1 2 4 3 1 2 3 3 4 3 3 4 1 3 4 3 2 3 3 3 3 2 2 3 4 1 3 3 3 2 5 2 5 2 3 5 2 1 2 1 1 3 4 2 2 4 4 4 3 2 1 3 4 5 5 1 1 3 2 1 2 3 3 3 1 2 4 5 2 5 3 1 5 1 5 3 3 3 2 1 5 2 4 2 5 2 2 3 4 5 2 2 5 5 4 5 3 3 2...

output:

643749194

result:

ok 1 number(s): "643749194"

Test #32:

score: 0
Accepted
time: 9ms
memory: 11612kb

input:

100000 1 5
4
3
4
3
1
4
5
3
4
4
3
4
3
4
2
1
5
1
2
4
4
1
1
3
1
2
5
2
3
1
4
1
3
1
2
2
3
5
3
5
2
2
4
4
3
1
4
3
3
1
2
2
3
2
2
4
3
4
2
3
2
1
5
4
2
3
3
3
1
4
5
5
1
5
3
2
1
3
3
5
4
4
4
4
4
3
1
4
5
2
5
2
4
4
1
3
2
2
1
4
1
4
1
4
4
3
3
5
4
4
1
2
3
2
1
4
4
5
2
2
5
5
2
2
1
2
3
3
1
4
2
3
1
3
5
1
4
5
4
4
5
4
3
3
1...

output:

74770400

result:

ok 1 number(s): "74770400"

Subtask #4:

score: 20
Accepted

Test #33:

score: 20
Accepted
time: 4ms
memory: 10524kb

input:

1 100000 1000
166 614 949 2 12 578 299 170 238 139 139 372 799 9 51 816 997 859 97 850 583 664 233 849 49 679 706 801 937 65 81 858 853 83 56 882 459 392 897 844 734 141 676 75 570 636 673 415 442 243 887 397 904 174 40 523 178 937 206 82 515 500 558 79 595 175 416 634 343 194 307 205 821 743 720 45...

output:

146179207

result:

ok 1 number(s): "146179207"

Test #34:

score: 0
Accepted
time: 17ms
memory: 10760kb

input:

100000 1 1000000000
819871275
769249822
49880450
466428026
819482075
687081154
257984054
522777003
244953370
721207440
746039961
520955695
988475172
782303686
418914210
937770960
90018053
425487954
41739587
118026105
141005785
363528873
983963383
205384665
622985725
500870812
362780970
541948003
116...

output:

212895976

result:

ok 1 number(s): "212895976"

Test #35:

score: 0
Accepted
time: 77ms
memory: 16864kb

input:

500000 1 10000000
8124231
8139566
8067722
8247139
8491399
8069713
8281872
8219066
8435757
8064629
8469417
8116648
8128853
8256643
8114005
8008523
8262529
8378350
8243345
8301854
8334623
8181161
8009989
8016331
8359038
8294039
8305470
8117959
8307018
8185069
8373221
8018982
8265631
8012023
8119737
80...

output:

789776572

result:

ok 1 number(s): "789776572"

Test #36:

score: 0
Accepted
time: 38ms
memory: 22836kb

input:

1 500000 500000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

958154505

result:

ok 1 number(s): "958154505"

Test #37:

score: 0
Accepted
time: 33ms
memory: 16936kb

input:

1 500000 500000
499999 499998 499997 499996 499995 499994 499993 499992 499991 499990 499989 499988 499987 499986 499985 499984 499983 499982 499981 499980 499979 499978 499977 499976 499975 499974 499973 499972 499971 499970 499969 499968 499967 499966 499965 499964 499963 499962 499961 499960 4999...

output:

958154505

result:

ok 1 number(s): "958154505"

Test #38:

score: 0
Accepted
time: 33ms
memory: 16924kb

input:

500000 1 10000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
8000000
80...

output:

393326022

result:

ok 1 number(s): "393326022"

Test #39:

score: 0
Accepted
time: 32ms
memory: 17000kb

input:

500000 1 10000000
4
3
4
3
3
4
3
2
2
4
4
2
3
2
4
4
4
4
2
2
2
4
3
4
3
4
3
2
2
2
3
4
2
4
2
2
4
4
3
4
3
3
3
3
3
2
4
3
2
4
2
2
2
2
2
2
4
4
2
3
2
2
3
3
3
2
3
2
3
3
4
4
2
3
2
2
3
4
4
2
4
3
2
2
2
3
2
4
2
3
3
3
2
3
2
2
2
4
3
3
4
2
4
4
4
4
2
4
3
2
3
3
4
2
4
2
2
4
2
2
4
3
4
2
2
4
3
3
3
2
4
4
2
4
2
3
4
4
2
3
2
...

output:

762531889

result:

ok 1 number(s): "762531889"

Test #40:

score: 0
Accepted
time: 6ms
memory: 13148kb

input:

1 100000 100000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

44735654

result:

ok 1 number(s): "44735654"

Test #41:

score: 0
Accepted
time: 2ms
memory: 11228kb

input:

1 100000 100000
99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 99...

output:

44735654

result:

ok 1 number(s): "44735654"

Test #42:

score: 0
Accepted
time: 12ms
memory: 10516kb

input:

100000 1 1000000000
868467946
879102077
556608519
900267986
493694174
52081019
765386749
316479420
822346094
494083606
399754378
827546691
623221959
147125986
267321540
550888219
469665265
724953898
447529844
910474032
979223048
240224373
45902204
168305508
166190793
920543747
336760574
422299368
12...

output:

540460232

result:

ok 1 number(s): "540460232"

Test #43:

score: 0
Accepted
time: 26ms
memory: 18740kb

input:

1 300000 300000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

427857066

result:

ok 1 number(s): "427857066"

Test #44:

score: 0
Accepted
time: 19ms
memory: 15440kb

input:

1 300000 300000
299999 299998 299997 299996 299995 299994 299993 299992 299991 299990 299989 299988 299987 299986 299985 299984 299983 299982 299981 299980 299979 299978 299977 299976 299975 299974 299973 299972 299971 299970 299969 299968 299967 299966 299965 299964 299963 299962 299961 299960 2999...

output:

427857066

result:

ok 1 number(s): "427857066"

Test #45:

score: 0
Accepted
time: 80ms
memory: 16940kb

input:

500000 1 1000000000
145933993
253929013
49295441
645670609
143450894
259598339
72707906
312713303
113854738
486869687
23245217
997673612
156935434
689132136
43824095
765617036
133904783
968382382
643074740
466990959
627926669
853798473
201229973
714318416
635498563
481624495
316384431
221850173
1176...

output:

516638533

result:

ok 1 number(s): "516638533"

Subtask #5:

score: 30
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #46:

score: 30
Accepted
time: 38ms
memory: 22752kb

input:

1000 500 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

967631222

result:

ok 1 number(s): "967631222"

Test #47:

score: 0
Accepted
time: 12ms
memory: 13160kb

input:

200 500 1000000000
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4...

output:

754573806

result:

ok 1 number(s): "754573806"

Test #48:

score: 0
Accepted
time: 78ms
memory: 19188kb

input:

600 500 1000000000
10000054 10000047 10000011 10000094 10000077 10000089 10000058 10000039 10000059 10000020 10000057 10000058 10000036 10000093 10000088 10000024 10000061 10000079 10000025 10000022 10000032 10000054 10000096 10000023 10000001 10000036 10000019 10000071 10000012 10000092 10000070 10...

output:

283245482

result:

ok 1 number(s): "283245482"

Test #49:

score: 0
Accepted
time: 90ms
memory: 18592kb

input:

600 500 1000000000
458152119 556959882 59276962 722335516 873955490 763168115 246601290 197808669 277822751 366462987 747465516 74214364 115182043 805517482 724370855 549739644 47929668 807541690 857516177 706027364 587520971 235043492 300415468 15401215 775355221 434361615 830592910 267145009 68675...

output:

478793597

result:

ok 1 number(s): "478793597"

Test #50:

score: 0
Accepted
time: 17ms
memory: 12548kb

input:

5 20000 1000
249 266 546 245 756 617 958 707 666 441 817 780 348 90 498 767 66 998 970 260 577 100 23 181 612 850 910 614 771 603 42 665 844 26 88 329 593 20 765 273 798 199 624 699 263 681 25 76 624 128 365 282 107 306 91 832 764 253 795 889 699 345 895 415 316 157 379 40 265 971 172 713 68 629 178...

output:

996736548

result:

ok 1 number(s): "996736548"

Test #51:

score: 0
Accepted
time: 18ms
memory: 11456kb

input:

20000 5 1000
966 668 88 457
556 415 425 670
178 611 388 587
831 422 47 69
30 636 892 82
106 119 322 33
840 826 574 460
486 804 863 824
925 640 310 181
420 474 225 530
861 559 197 845
911 268 720 672
323 787 718 382
991 979 234 984
907 983 333 533
820 192 307 193
659 792 261 564
667 41 78 334
176 35 ...

output:

441393624

result:

ok 1 number(s): "441393624"

Test #52:

score: 0
Accepted
time: 11ms
memory: 13900kb

input:

100 1000 123456789
123456789 123456789 123456789 1 123456789 123456789 1 123456789 123456789 123456789 123456789 1 123456789 1 1 123456789 123456789 1 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789...

output:

893558812

result:

ok 1 number(s): "893558812"

Test #53:

score: 0
Accepted
time: 7ms
memory: 12356kb

input:

1000 100 1000000000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

439843856

result:

ok 1 number(s): "439843856"

Test #54:

score: 0
Accepted
time: 12ms
memory: 12496kb

input:

100 1000 100
1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100...

output:

607723619

result:

ok 1 number(s): "607723619"

Test #55:

score: 0
Accepted
time: 12ms
memory: 12776kb

input:

300 300 100000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...

output:

183829456

result:

ok 1 number(s): "183829456"

Test #56:

score: 0
Accepted
time: 53ms
memory: 21316kb

input:

2 200000 1000000
200001 200000 199999 199998 199997 199996 199995 199994 199993 199992 199991 199990 199989 199988 199987 199986 199985 199984 199983 199982 199981 199980 199979 199978 199977 199976 199975 199974 199973 199972 199971 199970 199969 199968 199967 199966 199965 199964 199963 199962 199...

output:

287388356

result:

ok 1 number(s): "287388356"

Test #57:

score: 0
Accepted
time: 18ms
memory: 13808kb

input:

300 500 1000000000
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4...

output:

412129421

result:

ok 1 number(s): "412129421"

Test #58:

score: 0
Accepted
time: 22ms
memory: 15184kb

input:

300 500 1000000000
10000099 10000049 10000078 10000087 10000004 10000056 10000063 10000004 10000007 10000002 10000039 10000085 10000040 10000070 10000034 10000038 10000018 10000040 10000065 10000072 10000021 10000025 10000083 10000093 10000003 10000013 10000002 10000009 10000029 10000086 10000078 10...

output:

720182226

result:

ok 1 number(s): "720182226"

Test #59:

score: 0
Accepted
time: 65ms
memory: 15380kb

input:

400 500 1000000000
825979787 517384210 605059150 87903340 716435336 53216488 588876286 647041196 157207916 45428392 548628010 204044199 477361195 119644658 900192460 521598927 965969851 868943873 249308838 613045806 451152300 927583689 863848208 429916492 996288379 49640282 703298683 871690139 49580...

output:

586220878

result:

ok 1 number(s): "586220878"

Test #60:

score: 0
Accepted
time: 52ms
memory: 15328kb

input:

5 50000 1000
744 186 188 598 195 668 899 605 829 595 490 16 298 920 906 736 223 48 640 554 527 889 240 244 706 929 865 874 215 561 843 509 49 620 579 202 855 424 761 274 715 364 524 280 847 273 928 789 470 692 437 796 666 136 603 188 775 822 902 199 578 63 219 149 320 107 877 776 743 349 836 517 175...

output:

540962111

result:

ok 1 number(s): "540962111"

Test #61:

score: 0
Accepted
time: 100ms
memory: 23132kb

input:

100000 5 1000
927 903 189 352
672 344 447 937
19 958 584 538
14 947 700 566
237 840 203 235
912 911 653 126
470 45 611 180
23 618 661 877
761 501 411 791
169 692 974 471
804 623 748 343
46 57 550 465
749 24 803 964
511 199 975 513
254 6 918 276
454 283 791 854
977 929 254 9
696 117 989 128
306 590 2...

output:

182211925

result:

ok 1 number(s): "182211925"

Test #62:

score: 0
Accepted
time: 61ms
memory: 22016kb

input:

200 2000 123456789
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1 1 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567...

output:

588619884

result:

ok 1 number(s): "588619884"

Test #63:

score: 0
Accepted
time: 43ms
memory: 22836kb

input:

1000 500 1000000000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1000000000 1000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

28494588

result:

ok 1 number(s): "28494588"

Test #64:

score: 0
Accepted
time: 50ms
memory: 22896kb

input:

500 1000 100
1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100 1 100...

output:

967631321

result:

ok 1 number(s): "967631321"

Test #65:

score: 0
Accepted
time: 13ms
memory: 13224kb

input:

301 301 100000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...

output:

649457228

result:

ok 1 number(s): "649457228"

Test #66:

score: 0
Accepted
time: 73ms
memory: 22444kb

input:

2 250000 1250000
250001 250000 249999 249998 249997 249996 249995 249994 249993 249992 249991 249990 249989 249988 249987 249986 249985 249984 249983 249982 249981 249980 249979 249978 249977 249976 249975 249974 249973 249972 249971 249970 249969 249968 249967 249966 249965 249964 249963 249962 249...

output:

952514087

result:

ok 1 number(s): "952514087"