QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#579414 | #7775. 【模板】矩阵快速幂 | fryan | 25 | 561ms | 1038224kb | C++20 | 14.3kb | 2024-09-21 13:33:00 | 2024-09-21 13:33:01 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops")
#include "bits/stdc++.h"
using namespace std;
#define i32 int32_t
#define int int64_t
#define i128 __int128_t
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
const i32 BASE_DIGITS = 9, BASE = 1000000000;
struct BigInt {
i32 sign; vector<i32> a;
// Constructors
BigInt() : sign(1) {}
BigInt(long long v) { *this = v; }
BigInt& operator=(long long v) { sign = v < 0 ? -1 : 1; v = v < 0 ? -v : v; a.clear(); while(v > 0) {a.push_back(v % BASE); v /= BASE;} return *this; }
BigInt(const string& s) { read(s); }
// Input/Output
void read(const string& s) { sign = 1; a.clear(); i32 pos = 0; while(pos < (i32)s.size() && (s[pos] == '-' || s[pos] == '+')) { if(s[pos] == '-') sign = -sign; pos++; } for(i32 i = s.size()-1; i >= pos; i -= BASE_DIGITS) {i32 x = 0; for(i32 j = max(pos, i - BASE_DIGITS + 1); j <= i; j++) x = x * 10 + s[j] - '0'; a.push_back(x);} trim(); }
friend istream& operator>>(istream &stream, BigInt &v) { string s; stream >> s; v.read(s); return stream; }
friend ostream& operator<<(ostream &stream, const BigInt &v) { if(v.sign == -1 && !v.isZero()) stream << '-'; stream << (v.a.empty() ? 0 : v.a.back()); for(i32 i = (i32)v.a.size()-2; i >=0; --i) stream << setw(BASE_DIGITS) << setfill('0') << v.a[i]; return stream; }
// Comparison
bool operator<(const BigInt &v) const { if(sign != v.sign) return sign < v.sign; if(a.size() != v.a.size()) return a.size() * sign < v.a.size() * v.sign; for(i32 i = a.size()-1; i >=0; i--) if(a[i] != v.a[i]) return a[i] * sign < v.a[i] * sign; return false; }
bool operator>(const BigInt &v) const { return v < *this; }
bool operator<=(const BigInt &v) const { return !(v < *this); }
bool operator>=(const BigInt &v) const { return !(*this < v); }
bool operator==(const BigInt &v) const { return !(*this < v) && !(v < *this); }
bool operator!=(const BigInt &v) const { return *this < v || v < *this; }
friend i32 __compare_abs(const BigInt& x, const BigInt& y) { if(x.a.size() != y.a.size()) return x.a.size() < y.a.size() ? -1 : 1; for(i32 i = x.a.size()-1; i >=0; --i) if(x.a[i] != y.a[i]) return x.a[i] < y.a[i] ? -1 : 1; return 0; }
// Unary and Add/Sub
BigInt operator-() const { BigInt res = *this; if(!isZero()) res.sign = -sign; return res; }
void __internal_add(const BigInt& v) { if(a.size() < v.a.size()) a.resize(v.a.size(), 0); i32 carry = 0; for(i32 i = 0; i < max(a.size(), v.a.size()) || carry; ++i) { if(i == a.size()) a.push_back(0); a[i] += carry + (i < v.a.size() ? v.a[i] : 0); carry = a[i] >= BASE ? 1 : 0; if(carry) a[i] -= BASE; } }
void __internal_sub(const BigInt& v) { i32 carry = 0; for(i32 i = 0; i < v.a.size() || carry; ++i) { a[i] -= carry + (i < v.a.size() ? v.a[i] : 0); carry = a[i] < 0 ? 1 : 0; if(carry) a[i] += BASE; } trim(); }
BigInt operator+=(const BigInt& v) { if(sign == v.sign) { __internal_add(v); } else { if(__compare_abs(*this, v) >= 0) { __internal_sub(v); } else { BigInt vv = v; swap(*this, vv); __internal_sub(vv); } } return *this; }
BigInt operator-=(const BigInt& v) { if(sign == v.sign) { if(__compare_abs(*this, v) >= 0) { __internal_sub(v); } else { BigInt vv = v; swap(*this, vv); __internal_sub(vv); sign = -sign; } } else { __internal_add(v); } return *this; }
template<typename L, typename R>
typename enable_if<is_convertible<L, BigInt>::value && is_convertible<R, BigInt>::value && is_lvalue_reference<R&&>::value, BigInt>::type
friend operator+(L&& l, R&& r) { BigInt result(std::forward<L>(l)); result += r; return result; }
template<typename L, typename R>
typename enable_if<is_convertible<L, BigInt>::value && is_convertible<R, BigInt>::value && is_rvalue_reference<R&&>::value, BigInt>::type
friend operator+(L&& l, R&& r) { BigInt result(std::move(r)); result += l; return result; }
template<typename L, typename R>
typename enable_if<is_convertible<L, BigInt>::value && is_convertible<R, BigInt>::value, BigInt>::type
friend operator-(L&& l, R&& r) { BigInt result(std::forward<L>(l)); result -= r; return result; }
// Multiplication and Division
friend pair<BigInt, BigInt> divmod(const BigInt& a1, const BigInt& b1) { assert(b1 > 0); long long norm = BASE / (b1.a.back() + 1); BigInt a = a1.abs_val() * norm, b = b1.abs_val() * norm, q = 0, r = 0; q.a.resize(a.a.size()); for(i32 i = a.a.size()-1; i >=0; i--) { r *= BASE; r += a.a[i]; long long s1 = r.a.size() <= b.a.size() ? 0 : r.a[b.a.size()]; long long s2 = r.a.size() <= b.a.size()-1 ? 0 : r.a[b.a.size()-1]; long long d = (static_cast<long long>(BASE) * s1 + s2) / b.a.back(); r -= b * d; while(r < 0) { r += b; --d; } q.a[i] = d; } q.sign = a1.sign * b1.sign; r.sign = a1.sign; q.trim(); r.trim(); auto res = make_pair(q, r / norm); if(res.second < 0) res.second += b1; return res; }
BigInt operator/(const BigInt &v) const { return v < 0 ? divmod(-*this, -v).first : divmod(*this, v).first; }
BigInt operator%(const BigInt &v) const { return divmod(*this, v).second; }
void operator/=(i32 v) { assert(v > 0); if(static_cast<long long>(std::abs(static_cast<long long>(v))) >= BASE) { *this /= BigInt(v); return; } if(v < 0) { sign = -sign; v = -v; } i32 rem = 0; for(i32 i = a.size()-1; i >=0; --i) { long long cur = a[i] + static_cast<long long>(rem) * BASE; a[i] = cur / v; rem = cur % v; } trim(); }
BigInt operator/(i32 v) const { assert(v > 0); if(static_cast<long long>(std::abs(static_cast<long long>(v))) >= BASE) return *this / BigInt(v); BigInt res = *this; res /= v; return res; }
void operator/=(const BigInt &v) { *this = *this / v; }
long long operator%(long long v) const { assert(v > 0 && v < BASE); i32 m = 0; for(i32 i = a.size()-1; i >=0; --i) m = (a[i] + static_cast<long long>(m) * BASE) % v; return m * sign; }
void operator*=(i32 v) { if(static_cast<long long>(std::abs(static_cast<long long>(v))) >= BASE) { *this *= BigInt(v); return; } if(v < 0) { sign = -sign; v = -v; } i32 carry = 0; for(i32 i = 0; i < (i32)a.size() || carry; ++i) { if(i == a.size()) a.push_back(0); long long cur = static_cast<long long>(a[i]) * v + carry; carry = cur / BASE; a[i] = cur % BASE; } trim(); }
BigInt operator*(i32 v) const { if(static_cast<long long>(std::abs(static_cast<long long>(v))) >= BASE) return *this * BigInt(v); BigInt res = *this; res *= v; return res; }
// Base Conversion and FFT
static vector<i32> convert_base(const vector<i32> &a, i32 old_digits, i32 new_digits) { vector<long long> p(max(old_digits, new_digits)+1, 1); for(i32 i = 1; i < p.size(); i++) p[i] = p[i-1] * 10; vector<i32> res; long long cur = 0; i32 cur_digits = 0; for(auto num : a) { cur += num * p[cur_digits]; cur_digits += old_digits; while(cur_digits >= new_digits) { res.push_back(cur % p[new_digits]); cur /= p[new_digits]; cur_digits -= new_digits; } } res.push_back(static_cast<i32>(cur)); while(!res.empty() && !res.back()) res.pop_back(); return res; }
void fft(vector<complex<double>> &x, bool invert_flag) const { i32 n = x.size(); for(i32 i =1, j=0; i<n; i++){i32 bit = n>>1; while(j>=bit){j-=bit; bit>>=1;} j+=bit; if(i<j) swap(x[i], x[j]); } for(i32 len=2; len<=n; len <<=1){ double ang = 2 * 3.14159265358979323846 / len * (invert_flag ? -1 : 1); complex<double> wlen(cos(ang), sin(ang)); for(i32 i=0;i<n;i+=len){ complex<double> w(1); for(i32 j=0; j<len/2; ++j){ complex<double> u = x[i+j], v = x[i+j+len/2] * w; x[i+j] = u + v; x[i+j+len/2] = u - v; w *= wlen; } } } if(invert_flag) for(auto &c : x) c /= n; }
void multiply_fft(const vector<i32> &x, const vector<i32> &y, vector<i32> &res) const { vector<complex<double>> fa(x.begin(), x.end()), fb(y.begin(), y.end()); i32 n=1; while(n < max(x.size(), y.size())) n <<=1; n <<=1; fa.resize(n); fb.resize(n); fft(fa, false); fft(fb, false); for(i32 i=0;i<n;i++) fa[i] *= fb[i]; fft(fa, true); res.resize(n); long long carry=0; for(i32 i=0;i<n;i++) { long long t = round(fa[i].real()) + carry; carry = t / 1000; res[i] = t % 1000; } }
// Multiplication Methods
BigInt mul_simple(const BigInt &v) const { BigInt res; res.sign = sign * v.sign; res.a.resize(a.size() + v.a.size(), 0); for(i32 i=0;i<a.size();i++) if(a[i]) for(i32 j=0, carry=0; j < v.a.size() || carry; j++){ long long cur = res.a[i+j] + (static_cast<long long>(a[i]) * (j < v.a.size() ? v.a[j] : 0)) + carry; carry = cur / BASE; res.a[i+j] = cur % BASE; } res.trim(); return res; }
typedef vector<long long> vll;
static vll karatsubaMultiply(const vll &a, const vll &b) { i32 n=a.size(); vll res(n+n, 0); if(n <=32){ for(i32 i=0;i<n;i++) for(i32 j=0;j<n;j++) res[i+j] += a[i] * b[j]; return res; } i32 k=n>>1; vll a1(a.begin(), a.begin()+k), a2(a.begin()+k, a.end()), b1(b.begin(), b.begin()+k), b2(b.begin()+k, b.end()), a1b1 = karatsubaMultiply(a1, b1), a2b2 = karatsubaMultiply(a2, b2); for(i32 i=0;i<k;i++) { a2[i] += a1[i]; b2[i] += b1[i]; } vll r = karatsubaMultiply(a2, b2); for(i32 i=0;i<r.size();i++) res[i+k] += r[i] - (i < a1b1.size() ? a1b1[i] : 0) - (i < a2b2.size() ? a2b2[i] : 0); for(i32 i=0;i<a1b1.size();i++) res[i] += a1b1[i]; for(i32 i=0;i<a2b2.size();i++) res[i+n] += a2b2[i]; return res; }
BigInt mul_karatsuba(const BigInt &v) const { vector<i32> x6 = convert_base(a, BASE_DIGITS, 6), y6 = convert_base(v.a, BASE_DIGITS, 6); vll x(x6.begin(), x6.end()), y(y6.begin(), y6.end()); while(x.size() < y.size()) x.push_back(0); while(y.size() < x.size()) y.push_back(0); while(x.size() & (x.size()-1)) {x.push_back(0); y.push_back(0);} vll c = karatsubaMultiply(x, y); BigInt res; res.sign = sign * v.sign; long long carry=0; for(auto num : c) { long long cur = num + carry; res.a.push_back(cur % 1000000); carry = cur / 1000000; } res.a = convert_base(res.a, 6, BASE_DIGITS); res.trim(); return res; }
BigInt mul_fft(const BigInt& v) const { BigInt res; res.sign = sign * v.sign; multiply_fft(convert_base(a, BASE_DIGITS, 3), convert_base(v.a, BASE_DIGITS, 3), res.a); res.a = convert_base(res.a, 3, BASE_DIGITS); res.trim(); return res; }
void operator*=(const BigInt &v) { *this = *this * v; }
BigInt operator*(const BigInt &v) const { if(a.size() * v.a.size() <= 1000111) return mul_simple(v); if(a.size() > 500111 || v.a.size() > 500111) return mul_fft(v); return mul_karatsuba(v); }
// Miscellaneous
BigInt abs_val() const { BigInt res = *this; res.sign = 1; return res; }
void trim() { while(!a.empty() && !a.back()) a.pop_back(); if(a.empty()) sign = 1; }
bool isZero() const { return a.empty() || (a.size() == 1 && !a[0]); }
friend BigInt gcd(const BigInt &a, const BigInt &b) { return b.isZero() ? a : gcd(b, a % b); }
friend BigInt lcm(const BigInt &a, const BigInt &b) { return a / gcd(a, b) * b; }
friend BigInt sqrt(const BigInt &a1) { BigInt a = a1; while(a.a.empty() || a.a.size() % 2 == 1) a.a.push_back(0); i32 n = a.a.size(); i32 firstDigit = static_cast<i32>(sqrt(static_cast<double>(a.a[n-1]) * BASE + a.a[n-2])); i32 norm = BASE / (firstDigit + 1); a *= norm; a *= norm; while(a.a.empty() || a.a.size() % 2 == 1) a.a.push_back(0); BigInt r = static_cast<long long>(a.a[n-1]) * BASE + a.a[n-2]; firstDigit = static_cast<i32>(sqrt(static_cast<double>(a.a[n-1]) * BASE + a.a[n-2])); i32 q = firstDigit; BigInt res; for(i32 j = n/2-1; j >=0; j--){ while(1){ BigInt temp = (res * 2 * BigInt(BASE) + q) * q; if(!(r - temp < 0)) { r = r - temp; break; } --q; } res *= BASE; res += q; if(j > 0){ i32 d1 = res.a.size()+2 < r.a.size() ? r.a[res.a.size()+2] : 0, d2 = res.a.size()+1 < r.a.size() ? r.a[res.a.size()+1] : 0, d3 = res.a.size() < r.a.size() ? r.a[res.a.size()] : 0; q = ((static_cast<long long>(d1) * BASE * BASE + static_cast<long long>(d2) * BASE + d3) / (firstDigit * 2)); } } res.trim(); return res / norm; }
};
const int hv = 1e18;
BigInt b(i128 x) {
int f1 = x%hv;
BigInt r = f1;
x -= f1; x /= hv;
r += BigInt(hv)*BigInt(x);
return r;
}
std::ostream& operator<<(std::ostream& out, __int128 value) { char buffer[40], *ptr = &buffer[39]; *ptr = '\0'; bool neg = value < 0; if (neg) value = -value; do { *--ptr = '0' + (value % 10); value /= 10; } while (value); if (neg) *--ptr = '-'; return out << ptr; }
const i128 inf = 1e38;
const int mxn = 305;
const int mod = 998244353;
int n,m;
BigInt k;
int U[2*mxn],V[2*mxn],W[2*mxn]; //edges
i128 cyc[mxn][mxn];
i128 dist[mxn][mxn];
i128 d1[2*mxn*mxn][mxn];
BigInt dp[mxn*mxn][mxn];
BigInt MIN(BigInt a, BigInt b) {
if (a==BigInt(-1)) return b;
if (b==BigInt(-1)) return a;
return (a<b ? a : b);
}
void solve() {
cin>>n>>m>>k;
for (int i=0; i<m; i++) {
cin>>U[i]>>V[i]>>W[i];
--U[i]; --V[i];
}
for (int cs=0; cs<n; cs++) {
for (int i=0; i<=n; i++) {
for (int j=0; j<n; j++) {
dist[i][j] = inf;
}
}
dist[0][cs] = 0;
for (int i=1; i<=n; i++) {
for (int ne=0; ne<m; ne++) {
dist[i][V[ne]] = min(dist[i][V[ne]],dist[i-1][U[ne]]+W[ne]);
}
cyc[cs][i] = dist[i][cs];
}
}
for (int i=0; i<2*n*n+5; i++) {
for (int j=0; j<n; j++) {
d1[i][j] = inf;
}
}
d1[0][0] = 0;
for (int i=1; i<2*n*n+5; i++) {
for (int ne=0; ne<m; ne++) {
d1[i][V[ne]] = min(d1[i][V[ne]],d1[i-1][U[ne]]+W[ne]);
}
}
if (k <= BigInt(n*n*2)) {
int kv = k%((int)(1e8));
for (int i=0; i<n; i++) {
cout<<(d1[kv][i]==inf?(i128)-1:d1[kv][i]%mod)<<" ";
}
cout<<"\n";
return;
}
for (int i=0; i<=n*n+5; i++) {
for (int j=0; j<n; j++) {
dp[i][j] = -1;
}
}
for (int i=0; i<n; i++) {
i128 dd = d1[n*n][i];
if (dd==inf) continue;
for (int cl=1; cl<=n; cl++) {
if (cyc[i][cl]==inf) continue;
BigInt rem = k-BigInt(2*n*n-n);
BigInt amt = rem/cl;
int residue = rem%cl;
BigInt val = b(dd)+b(cyc[i][cl])*amt;
assert(residue <= n*n+5);
dp[residue+n*n-n][i] = MIN(dp[residue+n*n-n][i], val);
}
}
for (int cd = n*n+4; cd >= 0; cd--) {
for (int ne=0; ne<m; ne++) {
if (dp[cd+1][U[ne]] == BigInt(-1)) continue;
dp[cd][V[ne]] = MIN(dp[cd][V[ne]],dp[cd+1][U[ne]]+BigInt(W[ne]));
}
}
for (int i=0; i<n; i++) {
cout<<(dp[0][i])%mod<<" ";
}
cout<<"\n";
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int s,t; cin>>s>>t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 321ms
memory: 1019648kb
input:
1 1 100 101 899539897889989959 74 35 910832669819965536 35 85 910832669819965536 85 88 910832669819965536 88 30 910832669819965536 30 58 910832669819965536 58 60 910832669819965536 60 34 910832669819965536 34 8 910832669819965536 8 67 910832669819965536 67 89 910832669819965536 89 32 910832669819965...
output:
395495792 395495781 395495783 395495839 395495793 395495789 395495754 395495832 395495845 395495755 395495823 395495773 395495753 395495800 395495782 395495763 395495847 395495761 395495794 395495791 395495786 395495821 395495798 395495765 395495772 395495770 395495757 395495819 395495843 395495828 ...
result:
ok 100 numbers
Test #2:
score: 10
Accepted
time: 501ms
memory: 1021372kb
input:
1 1 100 200 998858598565699977 89 61 596014036562538539 89 84 921297646113897322 61 84 946923234442637386 61 35 641628261157284465 84 35 979893473772327497 84 78 700172488379560611 35 78 963617193748189613 35 54 951598888254521423 78 54 680825215292116806 78 21 737055858973038555 54 21 7491794406112...
output:
590375247 265938345 203065828 597548045 369717762 226160283 377877020 360218254 956162456 408060901 387231165 759578975 67601808 790211315 608425007 343195480 177353482 436533546 717630459 417099733 542227025 861764246 913806375 587268602 989846681 435016550 66609901 817090566 256847656 844441854 94...
result:
ok 100 numbers
Test #3:
score: 10
Accepted
time: 404ms
memory: 1019652kb
input:
1 1 100 181 348568663892999968 25 19 990622898175774733 19 94 871060999389241529 94 24 969317630558501400 24 43 908457844888427461 43 52 816088481082287266 52 62 978618931332609685 62 99 761714433396732044 99 85 741344935503895668 85 64 964684335126604843 64 69 988098065125373655 69 31 7506975506815...
output:
916998469 916998469 916998469 76035207 62461893 916998469 389136594 916998469 916998469 173423529 164423356 822964468 626456020 916998469 744111524 916998469 398953850 916998469 342238577 916998469 255074799 784015663 916998469 740933556 587088671 811719512 916998469 916998469 916998469 916998469 14...
result:
ok 100 numbers
Test #4:
score: 10
Accepted
time: 478ms
memory: 1022044kb
input:
1 1 100 189 295064635124730243 18 50 754672892083203214 50 88 962632394366987404 88 15 906700334097319336 15 26 967741400981618572 26 91 996214498763867892 91 35 882157548994344280 35 68 983621159612138407 68 51 563935036482744182 51 75 991205513962219551 75 72 974025375183814852 72 11 7979447663592...
output:
663199381 739882534 663199381 28600701 663199381 944601671 836329160 894091561 629507606 663199381 246830507 663199381 491987421 663199381 802123884 663199381 663199381 663199381 414785533 989396289 663199381 663199381 663199381 663199381 663199381 663199381 663199381 663199381 663199381 663199381 4...
result:
ok 100 numbers
Test #5:
score: 10
Accepted
time: 365ms
memory: 911724kb
input:
1 254 40 74 997173688939799978 38 6 890721839505665075 6 10 992308491267087930 10 29 960202932780090595 29 20 952827125924298715 20 34 868314670055961466 34 31 756448635709788087 31 14 857625921909632516 14 18 917667459973696862 18 21 985939328882662624 21 1 734882468602343649 1 11 66102593854575036...
output:
177014577 177014577 177014577 885341552 472856470 177014577 363547548 177014577 499847464 653076748 177014577 177014577 177014577 177014577 487939796 177014577 213466543 586729345 244952763 177014577 177014577 177014577 177014577 890105934 177014577 177014577 890105934 177014577 177014577 798890006 ...
result:
ok 3575 numbers
Test #6:
score: 10
Accepted
time: 294ms
memory: 904956kb
input:
1 356 32 47 967844399484634837 4 30 776954643355911997 30 20 811634053140142741 20 22 747630229183579429 22 2 806282875388761050 2 26 719793351534499411 26 17 797537828929335673 17 24 890423236992687627 24 21 970792227007588899 21 8 850078803097295262 8 15 958474507028658347 15 1 972636122087215360 ...
output:
890097469 525779071 636798453 776362497 776362497 687961593 158033324 776362497 345910504 380622623 239804834 440670451 137231885 985041116 222869127 137231885 705696901 637534644 347889826 696528073 291555427 146553026 776362497 624486185 137231885 642408114 520519927 137231885 438373632 263924254 ...
result:
ok 4784 numbers
Subtask #2:
score: 0
Time Limit Exceeded
Test #7:
score: 0
Time Limit Exceeded
input:
2 1 300 598 8179377797889487867988994778539839593376697796496698959964978969 1 2 977880533270721156 2 1 977880533270721156 2 3 977880533270721156 3 2 977880533270721156 3 4 977880533270721156 4 3 977880533270721156 4 5 977880533270721156 5 4 977880533270721156 5 6 977880533270721156 6 5 977880533270...
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 15
Accepted
Dependency #1:
100%
Accepted
Test #19:
score: 15
Accepted
time: 335ms
memory: 1038224kb
input:
4 1 100 101 6888995999928874698772868926699656683388498575797893294688976887 25 90 495511874996847106 90 84 495511874996847106 84 82 495511874996847106 82 40 495511874996847106 40 97 495511874996847106 97 5 495511874996847106 5 24 495511874996847106 24 16 495511874996847106 16 19 495511874996847106 ...
output:
662900138 662900131 662900188 662900147 662900176 662900221 662900152 662900202 662900130 662900140 662900169 662900199 662900128 662900145 662900192 662900178 662900163 662900150 662900179 662900151 662900139 662900180 662900216 662900177 662900170 662900205 662900210 662900183 662900184 662900125 ...
result:
ok 100 numbers
Test #20:
score: 15
Accepted
time: 561ms
memory: 1035668kb
input:
4 1 100 200 7298898492397999688666927949888498969897838287679988999656889979 1 68 716477084362826727 1 70 849254955511480878 68 70 965501875328180109 68 27 922798232695217800 70 27 973650788054328171 70 69 992887836560799260 27 69 912347321604310534 27 41 707737334645887057 69 41 939222694708421463 ...
output:
59219241 402083566 593666306 414807498 258758770 177911843 190858821 427609509 714942754 794670437 266523695 250908431 280340515 973300594 490891479 435411914 570632298 806776572 581872834 661756417 571008187 273666813 634277068 321782154 962526931 884883598 912195600 389101189 783089343 302322065 7...
result:
ok 100 numbers
Test #21:
score: 15
Accepted
time: 487ms
memory: 1037048kb
input:
4 1 100 170 8794888769994978795934858981288869698995675273759827929988816678 85 25 955229927087338794 25 69 715916767824027774 69 8 871119978520194455 8 64 918533454985251428 64 73 928715673496434787 73 95 777734955942460360 95 82 937506435422061091 82 21 972958971354009576 21 81 920481916656974333 ...
output:
1429581 1429581 150584952 1429581 1429581 616522075 1429581 1429581 56697037 26641870 455335474 405458157 1429581 119209248 768006956 56697037 1429581 1429581 56697037 825267652 337654936 589008244 691024955 410854366 1429581 1429581 569334223 757829937 1429581 1429581 1429581 387845353 1429581 1429...
result:
ok 100 numbers
Test #22:
score: 15
Accepted
time: 482ms
memory: 1019772kb
input:
4 1 100 175 988927424060208873 73 39 871487671517176049 39 12 989592888976857487 12 60 753594598459115125 60 80 804510907944284786 80 87 837728552224523957 87 50 720829671677245259 50 55 955472566241448463 55 56 698073335743612454 56 24 907173313658798936 24 75 812098650937527351 75 23 9749473294852...
output:
120476850 665961545 406533341 950211937 665961545 665961545 665961545 160438797 665961545 860608848 665961545 665961545 665961545 665961545 698344451 665961545 115173142 157625083 665961545 665961545 665961545 817070036 795455857 665961545 615381143 665961545 363716660 579107160 665961545 665961545 ...
result:
ok 100 numbers
Test #23:
score: 15
Accepted
time: 342ms
memory: 911552kb
input:
4 272 40 69 8526848846996917979164958976967645898953979497989749477999798947 16 20 904311791006766339 20 8 861881272650260368 8 38 927651150818983482 38 22 575472375470752507 22 10 995789624005306013 10 17 862458045607914444 17 35 910173488885856948 35 12 897609723109586512 12 23 970232607197909774 ...
output:
631006282 189710405 538148249 980737927 538148249 223767537 200756370 844883815 538148249 538148249 506622768 538148249 278823150 381947526 538148249 594558624 538148249 751430936 664913832 538148249 961366366 945739792 646619933 538148249 538148249 538148249 538148249 831302 107422344 538148249 118...
result:
ok 3782 numbers
Test #24:
score: 15
Accepted
time: 315ms
memory: 903680kb
input:
4 367 32 64 7694675676969676989727597922979586548768678479696836977677459878 26 1 948535512091890169 1 28 927579818325689242 28 18 869862583518920980 18 24 916474447302009020 24 23 592009716422157884 23 12 932781568469333631 12 17 906790845067818370 17 16 733495190715963829 16 5 948217995091033642 5...
output:
242947009 937164220 269122924 473901869 812915310 815200847 138502251 269122924 269122924 269122924 269122924 269122924 269122924 790732730 269122924 269122924 423399215 858100602 269122924 259562134 269122924 613550676 269122924 242947009 269122924 269122924 210817778 269122924 269122924 269122924 ...
result:
ok 4886 numbers
Subtask #5:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Test #25:
score: 0
Time Limit Exceeded
input:
5 1 300 301 969767789936486493 164 284 964646444984408140 284 241 964646444984408140 241 281 964646444984408140 281 138 964646444984408140 138 242 964646444984408140 242 112 964646444984408140 112 217 964646444984408140 217 170 964646444984408140 170 31 964646444984408140 31 300 964646444984408140 3...
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #3:
0%