#include<bits/stdc++.h>
using namespace std;
#include "Annalib.h"
#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;
template<class T>
inline bool asMn(T &a, const T &b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T &a, const T &b) { return a < b ? a = b, true : false; }
const LL infLL = 4e18;
void Anna(int N, int M, int A[], int B[], LL C[], int Q, int S[], int T[], int K, int U[]) {
vector<vector<LL> > d(N, vector<LL>(N, infLL) );
for (int u = 0; u < N; ++u) d[u][u] = 0;
for (int i = 0; i < M; ++i) d[ A[i] ][ B[i] ] = C[i];
for (int i = 0; i < K; ++i) d[ A[ U[i] ] ][ B[ U[i] ] ] = infLL;
for (int w = 0; w < N; ++w) {
for (int u = 0; u < N; ++u) {
for (int v = 0; v < N; ++v) {
asMn(d[u][v], d[u][w] + d[w][v]);
}
}
}
vector<int> group(Q, -1);
vector<LL> ans(Q);
for (int i = 0; i < Q; ++i) ans[i] = d[ S[i] ][ T[i] ];
vector<pair<int, int> > a;
for (int i = 0; i < K; ++i) {
vector<int> cnt(i + 1);
for (int j = 0; j <= i; ++j) cnt[j] = count(all(group), j - 1);
vector<int> cnt2(i + 1);
for (int j = 0; j < Q; ++j) if (asMn(ans[j], C[ U[i] ] + d[ S[j] ][ A[ U[i] ] ] + d[ B[ U[i] ] ][ T[j] ]) ) {
++cnt2[ group[j] + 1 ];
group[j] = i;
}
for (int j = 0; j <= i; ++j) a.emplace_back(cnt[j] + 1, cnt2[j]);
}
uint64_t tap = 0;
reverse(all(a) );
for (const auto &i : a) tap *= i.first, tap += i.second;
for (; tap; tap >>= 1) Tap(tap & 1);
}
#include<bits/stdc++.h>
using namespace std;
#include "Brunolib.h"
#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;
template<class T>
inline bool asMn(T &a, const T &b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T &a, const T &b) { return a < b ? a = b, true : false; }
const LL infLL = 4e18;
void Bruno(int N, int M, int A[], int B[], long long C[], int Q, int S[], int T[], int K, int U[], int L, int X[]) {
vector<vector<LL> > d(N, vector<LL>(N, infLL) ),
trace(N, vector<LL>(N, -1) );
for (int u = 0; u < N; ++u) d[u][u] = 0;
for (int i = 0; i < M; ++i) {
d[ A[i] ][ B[i] ] = C[i];
trace[ A[i] ][ B[i] ] = i;
}
for (int i = 0; i < K; ++i) {
d[ A[ U[i] ] ][ B[ U[i] ] ] = infLL;
trace[ A[ U[i] ] ][ B[ U[i] ] ] = -1;
}
for (int w = 0; w < N; ++w) {
for (int u = 0; u < N; ++u) {
for (int v = 0; v < N; ++v) {
if (asMn(d[u][v], d[u][w] + d[w][v]) ) trace[u][v] = trace[u][w];
}
}
}
auto get = [&](int iQ, int i, int j) {
return d[ S[iQ] ][ A[ U[j] ] ] + d[ B[ U[j] ] ][ T[iQ] ]
- (~i ? d[ S[iQ] ][ A[ U[i] ] ] + d[ B[ U[i] ] ][ T[iQ] ] : d[ S[iQ] ][ T[iQ] ]);
};
vector<int> group(Q, -1);
int tap = 0;
for (int i = 0; i < L; ++i) if (X[i]) tap |= 1 << i;
for (int i = 0; i < K; ++i) {
vector<vector<int> > iQ(i + 1);
for (int j = 0; j < Q; ++j) iQ[ group[j] + 1 ].emplace_back(j);
for (auto &j : iQ) {
sort(all(j), [&](const int &a, const int &b) {
return get(a, group[a], i) < get(b, group[b], i);
});
}
vector<int> cnt(i + 1);
for (int j = 0; j <= i; ++j) cnt[j] = (int)count(all(group), j - 1);
vector<int> tmp(i + 1);
for (int j = 0; j <= i; ++j) {
tmp[j] = tap % cnt[j];
tap /= cnt[j];
}
for (int j = 0; j <= i; ++j) {
for (int k = 0; k < tmp[j]; ++k) group[ iQ[j][k] ] = i;
}
}
function<void(int, int)> answer = [&](int u, int v) {
if (u == v) return ;
Answer(trace[u][v]);
answer(B[ trace[u][v] ], v);
};
for (int i = 0; i < Q; ++i) {
if (~group[i]) {
answer(S[i], A[ U[ group[i] ] ]);
Answer(U[ group[i] ]);
answer(B[ U[ group[i] ] ], T[i]);
}
else answer(S[i], T[i]);
Answer(-1);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
64 ms |
6684 KB |
Output isn't correct - Wrong Answer [9] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
73 ms |
10504 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
66 ms |
10504 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
66 ms |
10512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
75 ms |
10508 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Runtime error |
68 ms |
10276 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
3 |
Runtime error |
65 ms |
10396 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
4 |
Runtime error |
66 ms |
10508 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
5 |
Incorrect |
73 ms |
6916 KB |
Output isn't correct - Wrong Answer [4] |
6 |
Incorrect |
65 ms |
6932 KB |
Output isn't correct - Wrong Answer [9] |
7 |
Runtime error |
68 ms |
10516 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
8 |
Runtime error |
69 ms |
10536 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
9 |
Incorrect |
65 ms |
7224 KB |
Output isn't correct - Wrong Answer [9] |
10 |
Incorrect |
61 ms |
7060 KB |
Output isn't correct - Wrong Answer [9] |
11 |
Incorrect |
62 ms |
7056 KB |
Output isn't correct - Wrong Answer [9] |
12 |
Runtime error |
72 ms |
10628 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
13 |
Runtime error |
208 ms |
23172 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
14 |
Incorrect |
64 ms |
6948 KB |
Output isn't correct - Wrong Answer [4] |
15 |
Runtime error |
69 ms |
10512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
16 |
Runtime error |
86 ms |
10604 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
17 |
Runtime error |
87 ms |
10760 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
18 |
Incorrect |
89 ms |
7640 KB |
Output isn't correct - Wrong Answer [9] |
19 |
Runtime error |
66 ms |
10020 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
20 |
Runtime error |
80 ms |
11920 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
21 |
Runtime error |
93 ms |
11724 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
22 |
Incorrect |
61 ms |
7056 KB |
Output isn't correct - Wrong Answer [9] |
23 |
Incorrect |
62 ms |
7064 KB |
Output isn't correct - Wrong Answer [9] |
24 |
Runtime error |
66 ms |
10688 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |