QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#667694 | #9492. 树上简单求和 | hos_lyric# | 31 | 4923ms | 87088kb | C++14 | 15.2kb | 2024-10-23 02:56:55 | 2024-10-23 02:56:55 |
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")
struct Hld {
int n, rt;
// needs to be tree
// vertex lists
// modified in build(rt) (parent removed, heavy child first)
vector<vector<int>> graph;
vector<int> sz, par, dep;
int zeit;
vector<int> dis, fin, sid;
// head vertex (minimum depth) in heavy path
vector<int> head;
Hld() : n(0), rt(-1), zeit(0) {}
explicit Hld(int n_) : n(n_), rt(-1), graph(n), zeit(0) {}
void ae(int u, int v) {
assert(0 <= u); assert(u < n);
assert(0 <= v); assert(v < n);
graph[u].push_back(v);
graph[v].push_back(u);
}
void dfsSz(int u) {
sz[u] = 1;
for (const int v : graph[u]) {
auto it = std::find(graph[v].begin(), graph[v].end(), u);
if (it != graph[v].end()) graph[v].erase(it);
par[v] = u;
dep[v] = dep[u] + 1;
dfsSz(v);
sz[u] += sz[v];
}
}
void dfsHld(int u) {
dis[u] = zeit++;
const int deg = graph[u].size();
if (deg > 0) {
int vm = graph[u][0];
int jm = 0;
for (int j = 1; j < deg; ++j) {
const int v = graph[u][j];
if (sz[vm] < sz[v]) {
vm = v;
jm = j;
}
}
swap(graph[u][0], graph[u][jm]);
head[vm] = head[u];
dfsHld(vm);
for (int j = 1; j < deg; ++j) {
const int v = graph[u][j];
head[v] = v;
dfsHld(v);
}
}
fin[u] = zeit;
}
void build(int rt_) {
assert(0 <= rt_); assert(rt_ < n);
rt = rt_;
sz.assign(n, 0);
par.assign(n, -1);
dep.assign(n, -1);
dep[rt] = 0;
dfsSz(rt);
zeit = 0;
dis.assign(n, -1);
fin.assign(n, -1);
head.assign(n, -1);
head[rt] = rt;
dfsHld(rt);
assert(zeit == n);
sid.assign(n, -1);
for (int u = 0; u < n; ++u) sid[dis[u]] = u;
}
friend ostream &operator<<(ostream &os, const Hld &hld) {
const int maxDep = *max_element(hld.dep.begin(), hld.dep.end());
vector<string> ss(2 * maxDep + 1);
int pos = 0, maxPos = 0;
for (int j = 0; j < hld.n; ++j) {
const int u = hld.sid[j];
const int d = hld.dep[u];
if (hld.head[u] == u) {
if (j != 0) {
pos = maxPos + 1;
ss[2 * d - 1].resize(pos, '-');
ss[2 * d - 1] += '+';
}
} else {
ss[2 * d - 1].resize(pos, ' ');
ss[2 * d - 1] += '|';
}
ss[2 * d].resize(pos, ' ');
ss[2 * d] += std::to_string(u);
if (maxPos < static_cast<int>(ss[2 * d].size())) {
maxPos = ss[2 * d].size();
}
}
for (int d = 0; d <= 2 * maxDep; ++d) os << ss[d] << '\n';
return os;
}
bool contains(int u, int v) const {
return (dis[u] <= dis[v] && dis[v] < fin[u]);
}
int lca(int u, int v) const {
assert(0 <= u); assert(u < n);
assert(0 <= v); assert(v < n);
for (; head[u] != head[v]; ) (dis[u] > dis[v]) ? (u = par[head[u]]) : (v = par[head[v]]);
return (dis[u] > dis[v]) ? v : u;
}
int jumpUp(int u, int d) const {
assert(0 <= u); assert(u < n);
assert(d >= 0);
if (dep[u] < d) return -1;
const int tar = dep[u] - d;
for (u = head[u]; ; u = head[par[u]]) {
if (dep[u] <= tar) return sid[dis[u] + (tar - dep[u])];
}
}
int jump(int u, int v, int d) const {
assert(0 <= u); assert(u < n);
assert(0 <= v); assert(v < n);
assert(d >= 0);
const int l = lca(u, v);
const int du = dep[u] - dep[l], dv = dep[v] - dep[l];
if (d <= du) {
return jumpUp(u, d);
} else if (d <= du + dv) {
return jumpUp(v, du + dv - d);
} else {
return -1;
}
}
// [u, v) or [u, v]
template <class F> void doPathUp(int u, int v, bool inclusive, F f) const {
assert(contains(v, u));
for (; head[u] != head[v]; u = par[head[u]]) f(dis[head[u]], dis[u] + 1);
if (inclusive) {
f(dis[v], dis[u] + 1);
} else {
if (v != u) f(dis[v] + 1, dis[u] + 1);
}
}
// not path order, include lca(u, v) or not
template <class F> void doPath(int u, int v, bool inclusive, F f) const {
const int l = lca(u, v);
doPathUp(u, l, false, f);
doPathUp(v, l, inclusive, f);
}
// (vs, ps): compressed tree
// vs: DFS order (sorted by dis)
// vs[ps[x]]: the parent of vs[x]
// ids[vs[x]] = x, not set for non-tree vertex
vector<int> ids;
pair<vector<int>, vector<int>> compress(vector<int> us) {
// O(n) first time
ids.resize(n, -1);
std::sort(us.begin(), us.end(), [&](int u, int v) -> bool {
return (dis[u] < dis[v]);
});
us.erase(std::unique(us.begin(), us.end()), us.end());
int usLen = us.size();
assert(usLen >= 1);
for (int x = 1; x < usLen; ++x) us.push_back(lca(us[x - 1], us[x]));
std::sort(us.begin(), us.end(), [&](int u, int v) -> bool {
return (dis[u] < dis[v]);
});
us.erase(std::unique(us.begin(), us.end()), us.end());
usLen = us.size();
for (int x = 0; x < usLen; ++x) ids[us[x]] = x;
vector<int> ps(usLen, -1);
for (int x = 1; x < usLen; ++x) ps[x] = ids[lca(us[x - 1], us[x])];
return make_pair(us, ps);
}
};
////////////////////////////////////////////////////////////////////////////////
// T: (commutative) monoid representing information of an interval.
// T() should return the identity.
// T(S s) should represent a single element of the array.
// T::push(T &l, T &r) should push the lazy update.
// T::pull(const T &l, const T &r) should pull two intervals.
template <class X, class Y, class T> struct KdTree {
int n, nn;
// ((x, y), i): permuted
using Point = pair<pair<X, Y>, int>;
vector<Point> ps;
// leaf for point i
vector<int> us;
struct Node {
T t;
int l, r;
X minX, maxX;
Y minY, maxY;
};
vector<Node> nodes;
KdTree() : n(0), nn(0), ps(), us(), nodes() {}
void add(X x, Y y) {
const int i = ps.size();
ps.emplace_back(std::make_pair(x, y), i);
}
void build() {
n = ps.size();
assert(n >= 1);
us.resize(n);
nodes.resize(2 * n - 1);
buildRec(0, n, 0);
}
int buildRec(int jL, int jR, int dir) {
const int u = nn++;
Node &node = nodes[u];
node.minX = node.maxX = ps[jL].first.first;
node.minY = node.maxY = ps[jL].first.second;
if (jL + 1 == jR) {
us[ps[jL].second] = u;
node.l = node.r = -1;
} else {
for (int j = jL + 1; j < jR; ++j) {
if (node.minX > ps[j].first.first) node.minX = ps[j].first.first;
if (node.maxX < ps[j].first.first) node.maxX = ps[j].first.first;
if (node.minY > ps[j].first.second) node.minY = ps[j].first.second;
if (node.maxY < ps[j].first.second) node.maxY = ps[j].first.second;
}
const int jMid = jL + (jR - jL) / 2;
if (dir == 0) {
std::nth_element(ps.begin() + jL, ps.begin() + jMid, ps.begin() + jR,
[&](const Point &p0, const Point &p1) -> bool {
return (p0.first.first < p1.first.first);
});
} else {
std::nth_element(ps.begin() + jL, ps.begin() + jMid, ps.begin() + jR,
[&](const Point &p0, const Point &p1) -> bool {
return (p0.first.second < p1.first.second);
});
}
node.l = buildRec(jL, jMid, dir ^ 1);
node.r = buildRec(jMid, jR, dir ^ 1);
}
return u;
}
const T &all() const {
return nodes[0].t;
}
T &at(int i) {
return nodes[us[i]].t;
}
void pullAll() {
for (int u = nn; --u >= 0; ) if (~nodes[u].l) pull(u);
}
inline void push(int u) {
nodes[u].t.push(nodes[nodes[u].l].t, nodes[nodes[u].r].t);
}
inline void pull(int u) {
nodes[u].t.pull(nodes[nodes[u].l].t, nodes[nodes[u].r].t);
}
// Applies T::f(args...) to point i.
template <class F, class... Args>
void chLeaf(int i, F f, Args &&... args) {
chLeafRec(0, us[i], f, args...);
}
template <class F, class... Args>
void chLeafRec(int u, int leaf, F f, Args &&... args) {
Node &node = nodes[u];
if (u == leaf) {
(node.t.*f)(args...);
return;
}
push(u);
chLeafRec((leaf < node.r) ? node.l : node.r, leaf, f, args...);
pull(u);
}
// Calculates the value for point i.
T getLeaf(int i) {
return getLeafRec(0, us[i]);
}
T getLeafRec(int u, int leaf) {
Node &node = nodes[u];
if (u == leaf) {
return node.t;
}
push(u);
const T t = getLeafRec((leaf < node.r) ? node.l : node.r, leaf);
pull(u);
return t;
}
// Applies T::f(args...) to points in [xa, xb] * [ya, yb].
template <class F, class... Args>
void ch(X xa, X xb, Y ya, Y yb, F f, Args &&... args) {
chRec(0, xa, xb, ya, yb, f, args...);
}
template <class F, class... Args>
void chRec(int u, X xa, X xb, Y ya, Y yb, F f, Args &&... args) {
Node &node = nodes[u];
if (xb < node.minX || node.maxX < xa || yb < node.minY || node.maxY < ya) {
return;
}
if (xa <= node.minX && node.maxX <= xb && ya <= node.minY && node.maxY <= yb) {
(node.t.*f)(args...);
return;
}
push(u);
chRec(node.l, xa, xb, ya, yb, f, args...);
chRec(node.r, xa, xb, ya, yb, f, args...);
pull(u);
}
// Calculates the product for points in [xa, xb] * [ya, yb].
T get(X xa, X xb, Y ya, Y yb) {
return getRec(0, xa, xb, ya, yb);
}
T getRec(int u, X xa, X xb, Y ya, Y yb) {
Node &node = nodes[u];
if (xb < node.minX || node.maxX < xa || yb < node.minY || node.maxY < ya) {
return T();
}
if (xa <= node.minX && node.maxX <= xb && ya <= node.minY && node.maxY <= yb) {
return node.t;
}
push(u);
const T tL = getRec(node.l, xa, xb, ya, yb);
const T tR = getRec(node.r, xa, xb, ya, yb);
pull(u);
T t;
t.pull(tL, tR);
return t;
}
};
////////////////////////////////////////////////////////////////////////////////
template <class T> struct NodeSum {
int sz;
T sum;
T lz;
NodeSum() : sz(0), sum(0), lz(0) {}
NodeSum(const T &val) : sz(1), sum(val), lz(0) {}
void push(NodeSum &l, NodeSum &r) {
l.add(lz);
r.add(lz);
lz = 0;
}
void pull(const NodeSum &l, const NodeSum &r) {
sz = l.sz + r.sz;
sum = l.sum + r.sum;
}
void add(const T &val) {
sum += val * sz;
lz += val;
}
T getSum() const {
return sum;
}
bool accSum(T &acc, const T &tar) const {
if (acc + sum >= tar) return true;
acc += sum;
return false;
}
};
using Mint = unsigned long long;
int N, Q;
vector<Mint> C;
vector<int> A[2], B[2];
vector<int> X, Y;
vector<Mint> K;
Hld hld[2];
namespace subA {
int L, E;
vector<Mint> giant, baby;
Mint get(int u) {
const int a = hld[0].dis[u];
return C[u] + giant[a >> E] + baby[a];
}
vector<Mint> run() {
cerr<<"[subA::run]"<<endl;
for (E = 0; 1 << (2 * E) < N; ++E) {}
L = N >> E;
giant.assign(L + 1, 0ULL);
baby.assign(N, 0ULL);
vector<Mint> ans(Q, 0);
for (int q = 0; q < Q; ++q) {
hld[0].doPath(X[q], Y[q], true, [&](int l, int r) -> void {
for (int x = l >> E; x < r >> E; ++x) giant[x] += K[q];
for (int i = l >> E << E; i < l; ++i) baby[i] -= K[q];
for (int i = r >> E << E; i < r; ++i) baby[i] += K[q];
});
{
int x = X[q], y = Y[q];
for (; hld[1].dep[x] > hld[1].dep[y]; x = hld[1].par[x]) ans[q] += get(x);
for (; hld[1].dep[x] < hld[1].dep[y]; y = hld[1].par[y]) ans[q] += get(y);
for (; x != y; x = hld[1].par[x], y = hld[1].par[y]) ans[q] += get(x) + get(y);
ans[q] += get(x);
}
}
return ans;
}
} // subA
namespace subB {
vector<vector<int>> graph[2];
vector<int> D[2];
void dfs(int h, int u, int p, int d) {
D[h][u] = d;
for (const int v : graph[h][u]) if (p != v) {
dfs(h, v, u, d + 1);
}
}
bool check() {
for (int h = 0; h < 2; ++h) {
graph[h].assign(N, {});
for (int i = 0; i < N - 1; ++i) {
graph[h][A[h][i]].push_back(B[h][i]);
graph[h][B[h][i]].push_back(A[h][i]);
}
int cnt = 0;
for (int u = 0; u < N; ++u) if (graph[h][u].size() <= 1) ++cnt;
if (cnt > 2) return false;
}
return true;
}
vector<Mint> run() {
cerr<<"[subB::run]"<<endl;
for (int h = 0; h < 2; ++h) {
D[h].assign(N, -1);
for (int u = 0; u < N; ++u) if (graph[h][u].size() <= 1) {
dfs(h, u, -1, 0);
break;
}
// cerr<<"D["<<h<<"] = "<<D[h]<<endl;
}
KdTree<int, int, NodeSum<Mint>> kdt;
for (int u = 0; u < N; ++u) kdt.add(D[0][u], D[1][u]);
kdt.build();
for (int u = 0; u < N; ++u) kdt.at(u) = C[u];
kdt.pullAll();
vector<Mint> ans(Q, 0);
for (int q = 0; q < Q; ++q) {
{
int a = D[0][X[q]];
int b = D[0][Y[q]];
if (a > b) swap(a, b);
kdt.ch(a, b, 0, N - 1, &NodeSum<Mint>::add, K[q]);
}
{
int a = D[1][X[q]];
int b = D[1][Y[q]];
if (a > b) swap(a, b);
ans[q] = kdt.get(0, N - 1, a, b).sum;
}
}
return ans;
}
} // subB
int main() {
for (; ~scanf("%d%d", &N, &Q); ) {
C.resize(N);
for (int u = 0; u < N; ++u) {
scanf("%llu", &C[u]);
}
for (int h = 0; h < 2; ++h) {
A[h].resize(N - 1);
B[h].resize(N - 1);
for (int i = 0; i < N - 1; ++i) {
scanf("%d%d", &A[h][i], &B[h][i]);
--A[h][i];
--B[h][i];
}
}
X.resize(Q);
Y.resize(Q);
K.resize(Q);
for (int q = 0; q < Q; ++q) {
scanf("%d%d%llu", &X[q], &Y[q], &K[q]);
--X[q];
--Y[q];
}
for (int h = 0; h < 2; ++h) {
hld[h] = Hld(N);
for (int i = 0; i < N - 1; ++i) {
hld[h].ae(A[h][i], B[h][i]);
}
hld[h].build(0);
}
vector<Mint> ans;
if (subB::check()) {
ans = subB::run();
} else {
ans = subA::run();
}
for (int q = 0; q < Q; ++q) {
printf("%llu\n", ans[q]);
}
}
return 0;
}
详细
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 5ms
memory: 4904kb
input:
3000 3000 7236742292501328495 17973811477309806363 16075782662531676171 17971236571771878676 11392080645527132110 3685563455925680459 9773593720088356683 8313828403245053795 7736401634567449043 1634817828009987181 6951124933529719486 12775126714635387213 15460977209223753216 397573676785925632 31372...
output:
12105153858659381124 18367442707572066757 11668241962484097878 11288238120352358472 1742468310074622166 9942835997686093671 3305677510569607477 17741602000425004088 14984128302052618266 1075081718074605786 6509217537832509095 16750513627843273113 8569443169249732820 14475184194298579044 156111071108...
result:
ok 3000 lines
Test #2:
score: 5
Accepted
time: 5ms
memory: 4640kb
input:
3000 3000 1612333876155866602 8538417838700679227 6080765231437578796 17905224638340228394 12270907925903144224 17944105326358594564 17302041033966840611 1006351124625222126 496336153231744288 9393087977687876980 9553975238547373621 9361882717200384390 15051881329169144319 9757999873162420435 882725...
output:
11133131376095771981 7909873024850695144 16250639243139481926 14562550655578101207 8274205996508264973 178549413271904466 2368406276743327913 7464009386554813982 9439464815411774627 1471756740732097060 15201641099137019227 6774030298556871576 18156105511913219667 1553508745644446823 4225137078364117...
result:
ok 3000 lines
Test #3:
score: 5
Accepted
time: 3ms
memory: 4836kb
input:
3000 3000 9709246061666095435 1861649101703072889 10620139893353930613 17635186539135419482 710209455559527146 6075101384669982511 1120305006358459674 9703156967435388252 1397046737759839382 5259056712870179169 8253156305433022999 710199693203327302 15130650033641744675 10720111924616886955 15543351...
output:
7834604406305153073 5037061270969117785 16481572776620825702 15177894197606565804 3120320619896892806 18008650876379132344 7417108723176816402 13515164814425439399 3299769942258542105 15897528270699011770 11642805469843844638 16764682282380318054 4824039114054405772 4859834102876213962 1234210473247...
result:
ok 3000 lines
Test #4:
score: 5
Accepted
time: 4ms
memory: 5084kb
input:
3000 3000 16538965545220923528 18062192327708400751 10422465150728338588 3471522151129113073 1236650672072793692 1942240200040301168 13090729759591037952 15335798523677372669 9912100622761466753 11177948788405690381 3710859061697501523 4984944638666762977 17278589713462878008 6371292801024547050 868...
output:
8182453933067329108 13535217473847106938 17067385337010269798 3806121648880466130 11322569288575153037 11079197311131660121 9670138330007803226 6554062218199796758 965954569567598779 18055887214749050688 6142620503089407421 8690117812667761187 9547139298346295115 8890987597519353054 1755036654049586...
result:
ok 3000 lines
Test #5:
score: 5
Accepted
time: 8ms
memory: 4920kb
input:
3000 3000 17759588706587888497 10550000524636484378 11601004513528075994 7150322911283804521 4459707248078569712 10692395730842402625 8940418793863522991 12967068928670540447 9954278250450015940 13702413838608801301 10598390500439869870 15110245227553613794 490862872212325709 15164980555660957366 94...
output:
9743736929788175512 16812303667256960040 14694223512340829897 550204232580650311 1175342872438242313 17622261358285047637 7413682703975031220 12643066512274062227 1868985217436232595 5471830334855681322 8070132260376389587 3970361922096052085 218281824643752746 991917103472727104 2960248244218479023...
result:
ok 3000 lines
Subtask #2:
score: 12
Accepted
Dependency #1:
100%
Accepted
Test #6:
score: 12
Accepted
time: 0ms
memory: 4056kb
input:
5 7 0 3 2 6 4 1 2 2 4 1 5 5 3 3 4 4 2 2 5 5 1 5 3 0 3 2 5 4 4 4 4 4 3 5 2 0 3 4 3 5 5 6
output:
15 21 10 13 17 26 18
result:
ok 7 lines
Test #7:
score: 12
Accepted
time: 333ms
memory: 22524kb
input:
70000 70000 3805295436278888199 9842309351516174725 1566744796319231180 2206519284152256579 2715928675931950447 6346821976624501261 16020972671480798719 14702021753902144915 17127828773798978442 15779168055669690475 4964561323934614661 9395102787554964450 6377076753365184543 15167378195767668817 288...
output:
5971729064136092190 6457394048987305727 13604212649915736394 8639973959364892219 437861319070967556 16133076880026962355 5384937395694479961 4591478439775690843 16071919565966962790 15485626634068969082 10235993901046758372 3449528613427081475 8064280362779764074 12784984512326434905 424951714880051...
result:
ok 70000 lines
Test #8:
score: 12
Accepted
time: 2991ms
memory: 28096kb
input:
70000 70000 17769190865915081913 3772925482507158804 10559962993069063712 16307277356502651642 12014171661057147061 1923543107882042577 13408785599350410314 17786178374951015816 2038922879833426794 2540043772647346461 15419977514837351390 5175974305273838292 16815288359165841441 6295059675346852046 ...
output:
16215781699519408534 17067966839552063165 1639359200259068228 1157756671621253300 12850966537933214537 13917563606289473282 11146906493479190751 869141055866285398 529460535280965984 11437720548737856517 12321579881011015953 4005153170897692243 10217866116994297464 8892403813874757974 12520505236760...
result:
ok 70000 lines
Test #9:
score: 12
Accepted
time: 2398ms
memory: 28060kb
input:
70000 70000 1322605819855709761 1534349070722535975 3956030287626175223 12996546673549161162 7258680666490714729 15591023033141410544 11626890152249303179 7745771567168540351 5535931029756133379 11840793767439557739 6286106656048048381 9490665709724541446 4561258384162386434 2460318488748442222 1303...
output:
7565012138645637258 1080785033897684285 4000254219257999844 8727142139647715419 1784876728989450460 2474052717732723820 5108017366064709316 5232698473118606856 7893212823648229982 6449010654774296779 16571818815110297674 603759348329356530 7364528294111530037 4667545362378304836 3039728935129459889 ...
result:
ok 70000 lines
Test #10:
score: 12
Accepted
time: 4923ms
memory: 24708kb
input:
70000 70000 2918414982140182939 1004760492603077644 7526656799259998488 6665485253854847449 7752199419154649757 12763267823077347079 11745132191692540338 6726116817426709990 15550876907005962464 9760509858122842638 684733892856965421 10077915441058780247 8380400329996723109 16920573433866702239 3069...
output:
8230389499860859172 16425656898047941538 107743004356580170 9778122844868660722 11068387722102791183 13252614309136720348 15937842372230698728 12777338070107774364 17974062134369145560 3740400391792770609 7367804332878038809 14236246024207211797 5659238205278608512 10550373456364765526 3478082332928...
result:
ok 70000 lines
Test #11:
score: 12
Accepted
time: 2768ms
memory: 41468kb
input:
70000 70000 14167059704556856337 16190708842842354431 16763990539754009056 7631426709261583690 16701377874952853623 13128000186728267818 13668914249103068169 11444044591715948726 461080622438520919 15327533341012334586 15905150558482528923 18113008235210277231 18273290154232335325 871461822812191943...
output:
5416890687002400795 15434184693210288436 14994504916760087024 2057026449542829151 14782289435774270062 5375237679514404106 6242405047854012647 13176621545709355733 14860610197328732602 2320525143444929350 4955538191022622551 16072981679771537209 16493487770453132249 7457010288198365370 1095949888193...
result:
ok 70000 lines
Test #12:
score: 12
Accepted
time: 204ms
memory: 24048kb
input:
70000 70000 6512290618577097706 2307104154841663907 18099814251235047570 8297332016606109910 6979819983598849680 18022671181330012408 7003320957516774041 10765303713874539785 15263207007138552812 11713955610641877995 9084887894280210904 3653718255996209121 14197591595561260765 2937670413926210256 43...
output:
5372775214253596890 927985558228810546 3829815088328182672 17496384540548895622 2541458359607440535 9685902106698191409 13649653134779075960 2952563488513208867 3457470079648848247 11542323450217419837 6576344363223624061 12316990756988470568 17923006133291073450 13069551524451668138 648013229980407...
result:
ok 70000 lines
Test #13:
score: 12
Accepted
time: 3048ms
memory: 24048kb
input:
70000 70000 13665984219894847790 9458613748861462697 7467746948118990839 10855454155004540952 10025433108785732161 15816172836312183738 2834129139700401667 221649423184372325 8409217794427284711 16119623676185869010 12488380095384700010 3049877130176336551 5805665682633632307 13224802542929355280 18...
output:
7934210059911784858 14305091721658406168 5803801684631217062 8806866881905382618 14997911434771439753 7006465422324293550 15394754861139766679 8377831978907312075 12227086919743533414 8784212755151945751 17039860679476902214 6474495685436520748 11136139762939837997 16869294577244011226 1164744311638...
result:
ok 70000 lines
Subtask #3:
score: 0
Time Limit Exceeded
Dependency #2:
100%
Accepted
Test #14:
score: 0
Time Limit Exceeded
input:
120000 120000 4056283459929576306 2264755903151268173 1157390036441353969 5734735320959854923 6025999163810189446 3972481234804681969 4746636248696530169 6716674455256322787 6407347371842702902 7463142557880503801 208361219405474896 512530621977574257 6488145455921761864 6595856237657889728 95997703...
output:
result:
Subtask #4:
score: 14
Accepted
Test #21:
score: 14
Accepted
time: 1166ms
memory: 59356kb
input:
200000 200000 622783158027686223 2242697872372232537 8481648430436878777 10092474834140799044 15403999682625301609 12614289513474949582 9180944589267018841 7823784919308285798 8257785171198951273 5134508521895120821 8041682272181381093 3835432206618893170 2653803171409877650 5589823419153460372 1007...
output:
9042998055336671259 11611293489264521142 5835924579879681322 9187084356907537870 17810346410706951073 565636160725988981 837626748701483168 16059573289829807099 7246210357888652619 7725251776483176497 17088098442183693937 9042305714006927228 10907378739216215456 6526772063609981609 51578202456469609...
result:
ok 200000 lines
Test #22:
score: 14
Accepted
time: 1679ms
memory: 61580kb
input:
200000 200000 13175752638648662841 17926176333479943540 18069418271192836667 7662981418770774166 17432280672869071045 9361466030141569604 17336291298429915451 758279154724011577 10229986883918215412 16695796270233481895 1104033984864960726 9768530369533627193 7121962912997584423 8574667967472399164 ...
output:
761007177180158471 99932139211644879 9085452500188024811 10579196290428182519 9823187704909577710 18023302821814112676 12490017484705421441 12628966555486388857 14265121989865566834 6520346880672680237 13101459183526308131 999924043939340162 18263995506773932901 5204528109864295202 12531805215875429...
result:
ok 200000 lines
Test #23:
score: 14
Accepted
time: 1178ms
memory: 87088kb
input:
200000 200000 7686280868723494190 956703982700755675 9999621735507690021 16173863373498393354 13710049849600478540 17103229081434028663 17565545023679367555 2828484246894512005 1583487132574088302 6282276626784421099 11842426946394217784 3255349046251970557 9837219010639574935 8803965402777990679 10...
output:
9027980728293426417 390552393210324231 11163738403290403569 7251051512011369232 11710945043516484177 8385783841330898676 10540689232459717148 13494924758898800208 10783463309429788767 15497109458285729613 3973164643641949159 16591368938886703497 17545967451093599325 7502098747509618204 7748818626114...
result:
ok 200000 lines
Test #24:
score: 14
Accepted
time: 1254ms
memory: 64104kb
input:
200000 200000 3398335727711776744 2517912491303558304 9944108242783740552 11465445588414101188 8918103911029611319 6248803476150904656 13839544089125989886 11613304797643373734 2743278001758631252 5880657146483100262 17520221750013284250 3574310479117269847 17332054826892442501 4186477155186295241 7...
output:
11201243883635739649 5642768912062346910 14237324928813743475 17949858083662777758 7007085524141292752 16431646654432642924 9544485471385114348 17223214017002242047 6358064993672703329 7126356965173878837 10226578739676773239 17581948280120185856 7547085902091221485 2256786006467014785 1348515941789...
result:
ok 200000 lines
Test #25:
score: 14
Accepted
time: 1223ms
memory: 72156kb
input:
200000 200000 16389428600328688123 13285293781493429938 16272776262151288852 2788638121841944928 840590085080737028 472104557233550161 2950757076856426026 884621482021485766 4656207248358869553 4325985129321868698 15439653714414044259 8869605634233383357 2875651646205284961 18315661660942366682 3209...
output:
11670281421082997569 13170194106693978241 4379481616026191349 1374955090149450188 16981223657037354332 15581757479756062245 964815911596550839 14653197660590615612 1244503873454847903 12992317503104122180 8922002840354854569 9883361056075385805 4661992164326801469 5993972796274466263 476463508437351...
result:
ok 200000 lines
Test #26:
score: 14
Accepted
time: 1399ms
memory: 64172kb
input:
200000 200000 8926134977558578929 14277420964906340273 14017501029945049702 16291239250458096854 5699993893720160591 1404316482439341580 6509187990544574711 3321495986616857673 9576515208059172862 16437943937474607467 3444518963957979419 17039197068804123693 9035882298315219046 10231648064038856650 ...
output:
11394865482866208122 4540012560447567167 14181315197904653108 1138165850159307501 4403319165822720694 3554076031362588972 4848001086504005989 17788785233422248859 5278865852900446472 9052657317349052491 7439239802335183804 280124506773607363 4951887064424754895 4442074242463250219 112728736814611771...
result:
ok 200000 lines
Subtask #5:
score: 0
Time Limit Exceeded
Test #27:
score: 0
Time Limit Exceeded
input:
200000 200000 1958469220619413759 14991498002015735322 6054491201406941902 18206143187746582567 15082377615826460430 2936248617457291604 10073577150351675920 16534472678586906457 2207599132486246393 10301540360769075442 1492580560381080472 551692353431379140 13238280352539145808 8462626987240986565 ...
output:
result:
Subtask #6:
score: 0
Time Limit Exceeded
Test #34:
score: 0
Time Limit Exceeded
input:
200000 200000 6794776813641982926 1561596256197101737 10910039723053043515 7892247858295192798 12233819960547881004 17695389034783066733 9173201689566865598 17626618141377486739 7358781671024283919 6787559733384974662 3884392438269280436 14872846228351316833 9037842441501571648 14299818404271084016 ...
output:
result:
Subtask #7:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%