QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296365 | #4813. DS Team Selection | ucup-team087# | AC ✓ | 1620ms | 36836kb | C++14 | 9.2kb | 2024-01-02 20:12:52 | 2024-01-02 20:12:52 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
// add X^x Y^y (1-X)^-(a+1) (1-Y)^-(b+1)
// get [X^x Y^y]
// [X^x' Y^y'] X^x Y^y (1-X)^-(a+1) (1-Y)^-(b+1)
// = [x<=x'] [y<=y'] binom(x'-x+a,a) binom(y'-y+b,b)
// = [x<=x'] [y<=y'] (x'+1-x)^(rise a)/a! (y'+1-y)^(rise b)/b!
// = [x<=x'] [y<=y'] \sum[0<=a'<=a] \sum[0<=b'<=b] (x'+1)^(rise a')/a'! (-x)^(rise a-a')/(a-a')! (y'+1)^(rise b')/b'! (-y)^(rise b-b')/(b-b')!
template <class X, class Y, class T, int A, int B> struct StaticPrefixSumAdd {
// x^(rise a)/a!, y^(rise b)/b!
T xRise[A + 1], yRise[B + 1];
void riseX(int a, X x) {
static_assert(0 <= A); static_assert(A <= 4);
assert(0 <= a); assert(a <= A);
xRise[0] = 1;
if (a == 0) return;
X x0 = x;
xRise[1] = T(x0);
if (a == 1) return;
X x1 = x + 1;
((x0 % 2 == 0) ? x0 : x1) /= 2;
xRise[2] = T(x0) * T(x1);
if (a == 2) return;
X x2 = x + 2;
((x0 % 3 == 0) ? x0 : (x1 % 3 == 0) ? x1 : x2) /= 3;
xRise[3] = T(x0) * T(x1) * T(x2);
if (a == 3) return;
X x3 = x + 3;
((x0 % 2 == 0) ? x0 : (x1 % 2 == 0) ? x1 : (x2 % 2 == 0) ? x2 : x3) /= 2;
((x0 % 2 == 0) ? x0 : (x1 % 2 == 0) ? x1 : (x2 % 2 == 0) ? x2 : x3) /= 2;
xRise[4] = T(x0) * T(x1) * T(x2) * T(x3);
}
void riseY(int b, Y y) {
static_assert(0 <= B); static_assert(B <= 4);
assert(0 <= b); assert(b <= B);
yRise[0] = 1;
if (b == 0) return;
Y y0 = y;
yRise[1] = T(y0);
if (b == 1) return;
Y y1 = y + 1;
((y0 % 2 == 0) ? y0 : y1) /= 2;
yRise[2] = T(y0) * T(y1);
if (b == 2) return;
Y y2 = y + 2;
((y0 % 3 == 0) ? y0 : (y1 % 3 == 0) ? y1 : y2) /= 3;
yRise[3] = T(y0) * T(y1) * T(y2);
if (b == 3) return;
Y y3 = y + 3;
((y0 % 2 == 0) ? y0 : (y1 % 2 == 0) ? y1 : (y2 % 2 == 0) ? y2 : y3) /= 2;
((y0 % 2 == 0) ? y0 : (y1 % 2 == 0) ? y1 : (y2 % 2 == 0) ? y2 : y3) /= 2;
yRise[4] = T(y0) * T(y1) * T(y2) * T(y3);
}
struct QueryAdd {
int a, b;
X x;
Y y;
T val;
};
struct QueryGet {
X x;
Y y;
};
vector<QueryAdd> qsAdd;
vector<QueryGet> qsGet;
vector<T> anss;
void add(int a, int b, X x, Y y, T val) {
assert(0 <= a); assert(a <= A);
assert(0 <= b); assert(b <= B);
qsAdd.push_back(QueryAdd{a, b, x, y, val});
}
void get(X x, Y y) {
qsGet.push_back(QueryGet{x, y});
}
struct Array {
T t[A + 1][B + 1];
Array() : t{} {}
};
void run() {
const int qsAddLen = qsAdd.size(), qsGetLen = qsGet.size();
vector<pair<X, int>> events(qsAddLen + qsGetLen);
for (int i = 0; i < qsAddLen; ++i) events[i] = std::make_pair(qsAdd[i].x, i);
for (int j = 0; j < qsGetLen; ++j) events[qsAddLen + j] = std::make_pair(qsGet[j].x, qsAddLen + j);
std::sort(events.begin(), events.end());
vector<Y> ys(qsAddLen);
for (int i = 0; i < qsAddLen; ++i) ys[i] = qsAdd[i].y;
std::sort(ys.begin(), ys.end());
ys.erase(std::unique(ys.begin(), ys.end()), ys.end());
const int ysLen = ys.size();
vector<Array> bit(ysLen);
anss.assign(qsGetLen, 0);
for (const auto &event : events) {
if (event.second < qsAddLen) {
const int i = event.second;
const QueryAdd &q = qsAdd[i];
riseX(q.a, -q.x);
riseY(q.b, -q.y);
T val[A + 1][B + 1];
for (int a = 0; a <= q.a; ++a) for (int b = 0; b <= q.b; ++b) val[a][b] = q.val * xRise[q.a - a] * yRise[q.b - b];
for (int l = std::lower_bound(ys.begin(), ys.end(), q.y) - ys.begin(); l < ysLen; l |= l + 1) {
for (int a = 0; a <= q.a; ++a) for (int b = 0; b <= q.b; ++b) bit[l].t[a][b] += val[a][b];
}
} else {
const int j = event.second - qsAddLen;
const QueryGet &q = qsGet[j];
riseX(A, q.x + 1);
riseY(B, q.y + 1);
T sum[A + 1][B + 1] = {};
for (int l = std::upper_bound(ys.begin(), ys.end(), q.y) - ys.begin(); l > 0; l &= l - 1) {
for (int a = 0; a <= A; ++a) for (int b = 0; b <= B; ++b) sum[a][b] += bit[l - 1].t[a][b];
}
for (int a = 0; a <= A; ++a) for (int b = 0; b <= B; ++b) anss[j] += sum[a][b] * xRise[a] * yRise[b];
}
}
}
};
////////////////////////////////////////////////////////////////////////////////
constexpr unsigned MASK = (1U << 30) - 1;
int M;
vector<int> O;
vector<int> X[2], Y[2], D;
vector<unsigned> W;
vector<unsigned> ans;
void solve(int mL, int mR) {
if (mR - mL >= 2) {
const int mMid = (mL + mR) / 2;
solve(mL, mMid);
solve(mMid, mR);
StaticPrefixSumAdd<int, int, unsigned, 3, 1> f;
StaticPrefixSumAdd<int, int, unsigned, 3, 0> g, h;
for (int m = mL; m < mMid; ++m) if (O[m] == 1) {
/*
11111
12221
12321
12221
11111
*= (1-X)(1-Y)
+ -
+ -
+-
-+
- +
- +
Apart[]
+1 / (1-X)^2(1-Y)^2(1-XY)
= + 1 / (1-X)^3(1-Y)^2 - X / (1-X)^4(1-Y) + X^2 / (1-X)^4(1-XY)
-1 / (1-X)^2(1-Y)^2(1-XY^-1)
= - 1 / (1-X)^3(1-Y)^2 - X / (1-X)^4(1-Y) - XY^-1 / (1-X)^4(1-XY^-1)
X^x Y^y = X^(x-y) (XY)^y
X^x Y^y = X^(x+y) (XY^-1)^-y
*/
const int x0 = X[0][m] - D[m] + 1, x1 = X[0][m] + D[m];
const int y0 = Y[0][m] - D[m] + 1, y1 = Y[0][m] + D[m];
// cerr<<"m = "<<m<<": "<<make_pair(x0,y0)<<" "<<make_pair(x1+1,y1+1)<<"; "<<make_pair(x0,y1)<<" "<<make_pair(x1+1,y0-1)<<endl;
f.add(2, 1, x0, y0, +W[m]);
f.add(2, 1, (x1+1), (y1+1), -W[m]);
f.add(3, 0, x0 + 1, y0, -W[m]);
f.add(3, 0, (x1+1) + 1, (y1+1), +W[m]);
g.add(3, 0, x0 - y0 + 2, y0, +W[m]);
g.add(3, 0, (x1+1) - (y1+1) + 2, (y1+1), -W[m]);
f.add(2, 1, x0, y1, -W[m]);
f.add(2, 1, (x1+1), (y0-1), +W[m]);
f.add(3, 0, x0 + 1, y1, -W[m]);
f.add(3, 0, (x1+1) + 1, (y0-1), +W[m]);
h.add(3, 0, x0 + y1, -y1 + 1, -W[m]);
h.add(3, 0, (x1+1) + (y0-1), -(y0-1) + 1, +W[m]);
}
for (int m = mMid; m < mR; ++m) if (O[m] == 2) {
for (int s = 0; s < 2; ++s) for (int t = 0; t < 2; ++t) {
f.get(X[s][m], Y[t][m]);
g.get(X[s][m] - Y[t][m], Y[t][m]);
h.get(X[s][m] + Y[t][m], -Y[t][m]);
}
}
f.run();
g.run();
h.run();
// cerr<<"f.anss = "<<f.anss<<endl;
// cerr<<"g.anss = "<<g.anss<<endl;
// cerr<<"h.anss = "<<h.anss<<endl;
int j = 0;
for (int m = mMid; m < mR; ++m) if (O[m] == 2) {
for (int s = 0; s < 2; ++s) for (int t = 0; t < 2; ++t) {
ans[m] += ((s ^ t) ? -1 : +1) * (f.anss[j] + g.anss[j] + h.anss[j]);
++j;
}
}
}
}
int main() {
for (; ~scanf("%d", &M); ) {
O.assign(M, 0);
for (int s = 0; s < 2; ++s) {
X[s].assign(M, 0);
Y[s].assign(M, 0);
}
D.assign(M, 0);
W.assign(M, 0);
for (int m = 0; m < M; ++m) {
scanf("%d", &O[m]);
if (O[m] == 1) {
scanf("%d%d%d%u", &X[0][m], &Y[0][m], &D[m], &W[m]);
} else if (O[m] == 2) {
scanf("%d%d%d%u", &X[0][m], &X[1][m], &Y[0][m], &Y[1][m]);
--X[0][m];
--Y[0][m];
} else {
assert(false);
}
}
ans.assign(M, 0);
solve(0, M);
for (int m = 0; m < M; ++m) if (O[m] == 2) {
printf("%u\n", ans[m] & MASK);
}
#ifdef LOCAL
map<pair<int,int>,unsigned>f;
for(int m=0;m<M;++m){
if(O[m]==1){
for(int x=X[0][m]-D[m]+1;x<X[0][m]+D[m];++x)
for(int y=Y[0][m]-D[m]+1;y<Y[0][m]+D[m];++y)
{
f[make_pair(x,y)]+=W[m]*(unsigned)(D[m]-max(abs(x-X[0][m]),abs(y-Y[0][m])));
}
}else if(O[m]==2){
unsigned brt=0;
for(const auto&kv:f){
if(X[0][m]<kv.first.first &&kv.first.first <=X[1][m]&&
Y[0][m]<kv.first.second&&kv.first.second<=Y[1][m]){
brt+=kv.second;
}
}
if(brt!=ans[m]){
pv(f.begin(),f.end());
cerr<<brt<<" "<<ans[m]<<endl;
}
assert(brt==ans[m]);
}else{
assert(false);
}
}
#endif
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 4044kb
input:
4 1 3 4 5 1 2 1 4 3 5 1 2 4 2 2 2 4 5 3 5
output:
46 21
result:
ok 2 number(s): "46 21"
Test #2:
score: 0
Accepted
time: 7ms
memory: 4020kb
input:
998 2 551 711 262 646 2 128 467 106 519 1 558 927 450 66595084 1 361 809 208 60332548 1 515 957 618 80796575 2 284 931 117 684 1 896 611 247 70974392 1 11 714 426 87481360 2 881 968 136 697 1 454 562 451 86471007 1 101 439 155 51776388 2 2 672 46 246 1 524 268 227 93245818 2 223 697 669 757 1 162 72...
output:
0 0 865123352 72746388 850072396 798324882 774403614 216523785 291994372 252858880 633224401 1023164015 927266681 704934823 613223554 326574162 31121370 165845274 710425585 1008427115 478409704 774115858 81820823 1028825544 236200928 1044043263 21324351 108862558 279895600 371112374 533411993 237570...
result:
ok 504 numbers
Test #3:
score: 0
Accepted
time: 3ms
memory: 4008kb
input:
1000 2 49137835 70671601 18873956 45874590 2 62645552 74753238 40096924 44551254 1 23512931 60954680 18957528 96359308 1 44828075 13659883 84702582 21556355 2 81019283 90444820 9236193 67066200 1 76455432 68444319 69049734 71359001 1 85968266 38618636 64564140 25708147 2 71871355 83958298 82270065 8...
output:
0 0 283578221 119903392 280174084 587234423 830444436 266626034 251202955 952481576 363239411 933156865 695412350 120684074 275453831 370390065 552584676 1002405616 311611347 633585565 159628784 1052494607 307772622 1045418949 625999458 692573127 859700262 675316552 313567150 575197528 937579202 226...
result:
ok 501 numbers
Test #4:
score: 0
Accepted
time: 214ms
memory: 7360kb
input:
20000 1 12645 2866 6360 60038699 2 8600 18135 583 6439 2 10455 12223 3170 6140 2 529 19186 6791 15927 1 19027 13358 4796 45848953 2 452 9407 783 5737 1 825 9101 3288 89339793 2 505 6673 8300 19607 1 6666 4078 768 62504799 2 29 4217 9803 17639 1 3785 1586 5932 98262710 2 14170 18816 10657 19226 1 135...
output:
649076427 948797588 398109766 155232147 1050171013 234845551 731500633 262944450 731174161 985456452 233892162 147795336 1047411174 204761351 759857964 39953660 495050735 469908224 227421565 746309996 779762035 457768132 1056781031 734873596 254189680 39933239 548847625 658668744 612765985 592063101...
result:
ok 9934 numbers
Test #5:
score: 0
Accepted
time: 220ms
memory: 7548kb
input:
20000 1 35875808 41271162 15649261 97332439 1 60076055 10670568 46206805 4708435 1 80941697 55158038 27140631 64994669 1 81072601 37732247 67252873 95838598 2 13889716 31487760 18360212 54776354 1 64013319 52784196 1192954 26367316 2 13309550 67584319 44787440 79611197 1 94074392 1816309 59697919 14...
output:
959644379 520591272 678805150 799769290 291949562 231926815 370207939 50423944 683713972 184406145 488458300 975817382 728264554 585589401 555884719 852635213 21949908 613357018 5199310 798644890 158681267 146133482 818203446 420974202 181731921 276745474 467358724 291701152 237483093 347826791 1040...
result:
ok 9983 numbers
Test #6:
score: 0
Accepted
time: 485ms
memory: 11208kb
input:
40000 1 24477 15043 28779 381837 2 6407 29715 3734 26742 2 21502 24741 3756 4921 2 24035 27587 10883 16422 2 4167 15193 8572 17212 2 31573 35239 13565 33543 2 10834 15825 12847 17600 1 13719 16868 17452 48868568 1 10849 5983 13723 17231005 1 25322 31268 11927 4957959 2 33389 33467 161 34981 2 27674 ...
output:
942520624 832292632 534228654 438904562 1068346239 404526720 417918862 238527871 1017668887 229430316 1051172113 236484689 295464858 359174442 610140037 709463512 938121288 766371103 238353432 106469718 297116802 505928402 203511543 193621995 128437244 748796655 426101131 303424013 659843159 4089861...
result:
ok 19894 numbers
Test #7:
score: 0
Accepted
time: 486ms
memory: 11400kb
input:
39996 2 14398076 47189365 25223993 32485788 1 27404693 23456287 55354605 76894669 2 12718401 99241315 6986342 42231497 1 26939327 4572122 39427634 38908170 2 8541583 12741036 61299 68911467 2 57381301 99213031 17399196 23972914 1 19243565 65499724 35495025 1875339 1 60573965 95550457 49508796 816574...
output:
0 1023384377 535237129 966847501 431567368 480423347 493135712 55586415 453728552 9196285 877756005 612079740 826695744 513854135 309218300 117613646 962155971 154976262 106291611 991802214 321154632 879250687 823779625 488895704 65601581 336190911 13156163 285363313 958869547 925631647 347129146 10...
result:
ok 19837 numbers
Test #8:
score: 0
Accepted
time: 770ms
memory: 14104kb
input:
60000 2 1244 25287 1116 40310 1 28643 43078 9088 64014005 1 21653 7613 58290 49776046 1 27897 27965 57716 51238467 2 27957 42988 14033 37349 2 35178 38145 18010 41957 2 13455 30014 24744 34418 2 52745 56844 32461 53197 1 12812 2194 28203 84445563 1 17389 21680 3251 65393869 1 21226 6499 21189 261941...
output:
0 867152932 506363671 544065420 424565186 328219495 968765637 545575429 533102406 414318336 437873626 462003967 990157221 791816093 351869684 102865090 16258317 123255150 177831311 937868926 1000441411 60689323 742106254 473428287 990157869 760105960 755562381 272476566 797108514 147385751 716643120...
result:
ok 29952 numbers
Test #9:
score: 0
Accepted
time: 774ms
memory: 14664kb
input:
60000 1 98378453 54382890 45176081 59520425 1 33986858 83703947 92586675 5398466 2 5970804 93121855 978357 68083043 2 21728231 63957955 9235536 16021368 1 82626059 10489401 75610240 80170176 2 48539084 79694254 34828432 92785760 2 71094153 86043819 4331292 73343754 1 89675821 16878006 23920520 63715...
output:
646438944 500894480 911202059 417069480 81528438 480895104 232330822 870766304 473193107 930581740 94244303 133205960 982567214 19107930 748983217 403172993 948951065 509505894 454439423 468364554 235287395 409946414 423142358 620909328 523200586 295320790 890455712 393989387 12384303 44886632 52516...
result:
ok 29870 numbers
Test #10:
score: 0
Accepted
time: 1069ms
memory: 20744kb
input:
79997 2 19778 25444 8100 61577 2 4574 24766 12981 14024 1 69341 70212 18311 15650930 2 10892 15120 32290 55142 1 36553 7664 38320 1288519 1 6872 25148 10772 97851181 1 27537 71318 23522 26962551 1 67940 7793 56125 4467657 1 77525 35799 78383 52467566 1 11284 77961 9681 20103911 2 47441 61710 30379 7...
output:
0 0 0 567184258 565003013 562478264 179874432 303219712 920631814 352920370 510309774 491583906 218691060 251542939 92510518 1070657194 478707142 433167012 437017048 805395186 813728481 1027906179 341479493 908764813 681531408 565829393 917720019 941826337 879790869 603348263 745259514 215549470 343...
result:
ok 39999 numbers
Test #11:
score: 0
Accepted
time: 1058ms
memory: 19896kb
input:
79997 1 36696271 41216261 96326194 62696256 2 19810443 52576336 262983 53774996 1 97666207 4432633 35889233 42146442 1 81532281 55149059 42520921 57325424 2 12122185 89775406 52099353 55361961 2 563070 36509043 96726240 96854363 1 26431754 48604940 2981416 49044638 2 49491178 97195825 47480140 91181...
output:
61574144 185869392 174584576 302599040 765518428 452330918 192548356 947873571 514727486 1068708423 439751319 633268755 969643203 235187384 750411187 451005249 605712013 257223298 582921046 197813999 1043015301 529116764 309667986 877519643 988474139 804279112 432291138 946341401 924454707 828761623...
result:
ok 40069 numbers
Test #12:
score: 0
Accepted
time: 1294ms
memory: 36252kb
input:
100000 1 34380 11421 6894 5421501 1 14317 42540 9268 76794286 1 24981 27368 32903 80438213 1 19432 85459 45142 91474294 1 36996 66026 42309 84168947 1 94561 54868 62797 6492386 1 43237 84001 20645 65733571 1 50054 74924 2714 72370240 1 33891 57907 76375 2662996 1 73360 18612 73561 59515230 1 74114 7...
output:
148876392 961410585 419839061 141672616 121996678 102979758 1025962479 555097376 200804515 613812385 805960503 73778093 80100787 275869683 601941514 149124890 869355373 311993802 423760390 499922791 709093821 754861967 338701217 604004520 166235232 60767414 255270250 370488815 1030265672 232402411 6...
result:
ok 50000 numbers
Test #13:
score: 0
Accepted
time: 1620ms
memory: 36836kb
input:
100000 1 33530298 1200235 32300428 21036259 1 90929480 41868440 70071824 79921886 1 94836015 74305971 92763837 32401800 1 78818280 30839372 84264497 62051402 1 48477131 30560030 639775 10073178 1 42166977 65863007 39554976 87495793 1 67356181 47808477 80716790 32207885 1 73456961 88772936 82465051 2...
output:
832214329 158835942 828195654 42699425 1011101117 403691743 890075196 227362193 749630070 587629877 725362293 321338449 910032482 705896517 19637806 626069255 840720379 257763227 1000157334 182911450 713926675 724299559 607900440 1032365109 364821448 227254038 985435706 502400153 675887222 966888194...
result:
ok 20326 numbers
Test #14:
score: 0
Accepted
time: 1222ms
memory: 22020kb
input:
99998 2 60156 60161 73255 73260 2 74890 74895 16915 16920 2 86184 86189 53538 53543 2 94635 94640 45305 45310 2 46788 46793 46995 47000 2 56664 56669 63605 63610 1 61984 89188 2 38368837 2 66407 66412 95069 95074 2 50982 50987 30601 30606 2 75820 75825 91943 91948 1 70827 90425 5 36463542 2 69287 69...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 49708 numbers
Test #15:
score: 0
Accepted
time: 1177ms
memory: 22692kb
input:
100000 1 86436691 6108307 3 53041518 2 55197814 55197819 58054356 58054361 2 43151707 43151712 98934930 98934935 1 28934640 2328977 4 2373200 2 64805939 64805944 95487216 95487221 2 66902152 66902157 99157483 99157488 2 54671122 54671127 91291299 91291304 2 60859348 60859353 70878593 70878598 1 8434...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 49989 numbers
Test #16:
score: 0
Accepted
time: 1312ms
memory: 21392kb
input:
99996 1 11500 1524 5 10014694 1 95816 72482 5 10140174 1 12358 21555 5 58438000 2 13281 35573 7833 9556 2 29575 44915 39972 61032 2 48961 76713 54659 84942 1 12505 1046 5 59961488 2 39117 92428 44528 52757 1 41493 57978 5 735953 1 49893 65640 5 20431787 2 44314 93165 363 50633 2 83728 95770 38078 78...
output:
0 0 0 0 0 0 0 894411802 103924520 894900226 103924520 0 121432245 143327085 271451628 1002815938 0 262050874 0 78537612 544727156 0 0 0 740218108 440585 558086037 345678372 37503289 524823800 121432245 427192286 0 1047860448 402873167 100437840 649634054 810525035 0 555410358 150019383 0 1020957119 ...
result:
ok 50077 numbers
Test #17:
score: 0
Accepted
time: 1341ms
memory: 22288kb
input:
99995 1 72131666 12334058 5 34265674 2 11863282 97072975 72626352 90833011 1 31981854 47799985 2 5266163 2 49016880 59235746 6819244 18682811 1 55699971 3191506 4 3470511 1 39383413 45308224 5 66538067 1 18076832 7347410 4 72246600 2 2426337 54162184 613949 60765314 2 23018906 78886521 74070057 8006...
output:
0 0 994029725 0 0 0 0 0 677110257 146870170 0 0 823980427 677110257 0 0 0 639016043 385385768 657600989 626748583 968676622 0 677110257 0 0 294024445 0 181649103 388291089 76220771 146870170 360476996 826169906 23241557 1032812637 350974358 822585773 134011751 0 21231581 0 350974358 604354516 0 4940...
result:
ok 49816 numbers
Test #18:
score: 0
Accepted
time: 1364ms
memory: 22296kb
input:
100000 1 3852 55739 98740 96211606 1 30204 8583 6739 69713251 2 18698 73644 57103 97611 2 64459 73969 2309 10342 2 19039 52338 20689 37499 1 3500 25338 72549 12736124 2 25057 29166 63599 81163 2 26634 57184 4493 78479 1 42976 66205 67971 40409393 2 77850 93993 32109 55238 1 17647 64780 89003 8973547...
output:
837284522 907079272 957593004 1013123768 413315843 559718096 469224949 269276365 730104495 515905984 704620230 634149640 520149089 15280064 72940269 108516865 854999906 229229979 518651515 149799289 899063715 502076504 469547118 957072927 389085487 107438668 925418973 857736589 593123400 304374432 9...
result:
ok 50088 numbers
Test #19:
score: 0
Accepted
time: 1380ms
memory: 22352kb
input:
100000 2 31074951 52328678 46926364 74309944 1 65226742 66402750 67441739 47235396 2 2751124 47213164 19878396 44911725 2 70943708 95737950 5935487 39364772 1 33996961 93533623 8662969 90069972 2 52436199 99095174 86229296 93221180 2 5042501 52974285 1860599 46027420 2 66016129 67588602 50202859 561...
output:
0 779360104 890218708 285795428 451307612 684935272 218232434 130553196 245698666 1034654856 857003514 854269169 521066624 629250333 571222758 799039191 22368757 469949920 145387007 457410491 425555305 983064205 810216570 331629952 243291224 739676817 627349941 759164920 197945379 641163157 71374732...
result:
ok 50103 numbers
Test #20:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
1 1 1 1 1 1
output:
result:
ok 0 number(s): ""
Test #21:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
1 2 1 1 1 1
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
2 2 1 1 1 1 1 1 1 1 1
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 1205ms
memory: 26328kb
input:
100000 1 99999992 100000000 99999990 99999999 1 99999993 100000000 99999998 99999994 1 99999998 99999995 99999999 100000000 1 99999995 99999991 99999994 99999997 1 99999992 99999990 100000000 99999996 1 99999998 100000000 99999990 99999990 1 99999999 99999990 99999992 99999999 1 99999997 99999993 10...
output:
898153686 908753639 575940149 905570939 97509622 891946487 545601006 1013368397 763405628 99157101 325230094 1028554564 787066555 833244742 771963643 562235831 755583279 906657062 487111315 817791150 844489054 447509894 75009384 69962446 175505088 465467452 282743241 251020240 48748040 392777579 514...
result:
ok 5000 numbers
Test #24:
score: 0
Accepted
time: 758ms
memory: 15692kb
input:
100000 2 99999997 99999997 99999994 99999998 2 99999995 99999998 99999995 100000000 2 99999992 99999996 99999997 99999998 2 99999993 99999999 99999998 100000000 2 99999997 99999999 99999996 99999997 2 99999994 99999998 99999999 99999999 2 99999994 99999998 99999990 99999991 2 99999992 99999995 99999...
output:
0 0 0 0 0 0 0 0 314342893 309632433 256260605 33857368 761293069 681341091 752194178 578452309 78452334 1049911398 306071026 449560837 343167772 896539575 707599212 651016568 209632438 352194198 275775065 563398745 282591295 191295513 573170184 260649204 734713019 225364529 830324415 277559030 28219...
result:
ok 95000 numbers
Test #25:
score: 0
Accepted
time: 1206ms
memory: 25440kb
input:
100000 1 99999995 99999998 99999993 99999992 1 99999997 99999999 100000000 99999990 1 99999992 99999998 99999993 99999993 1 99999993 100000000 99999995 100000000 1 100000000 99999993 99999990 99999997 1 99999994 99999995 99999994 99999995 1 99999994 99999995 99999999 99999994 1 99999990 99999994 999...
output:
638331431
result:
ok 1 number(s): "638331431"
Test #26:
score: 0
Accepted
time: 664ms
memory: 14888kb
input:
100000 2 99999994 99999998 99999990 99999995 2 99999990 99999999 99999998 100000000 2 99999992 99999999 99999994 99999996 2 99999990 99999993 99999991 99999992 2 99999995 99999997 99999993 99999993 2 99999994 99999999 99999992 99999994 2 99999994 99999997 99999995 99999996 2 99999993 99999995 999999...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 99999 numbers