# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
218673 |
2020-04-02T13:42:12 Z |
EntityIT |
한자 끝말잇기 (JOI14_kanji) |
C++14 |
|
215 ms |
17500 KB |
#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] + 1);
tap /= cnt[j] + 1;
}
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);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
6560 KB |
Output is correct - L = 19 |
2 |
Correct |
63 ms |
6688 KB |
Output is correct - L = 20 |
3 |
Correct |
63 ms |
6784 KB |
Output is correct - L = 4 |
4 |
Correct |
63 ms |
6564 KB |
Output is correct - L = 25 |
5 |
Correct |
62 ms |
6792 KB |
Output is correct - L = 25 |
6 |
Correct |
63 ms |
6572 KB |
Output is correct - L = 22 |
7 |
Correct |
61 ms |
6684 KB |
Output is correct - L = 19 |
8 |
Correct |
69 ms |
6684 KB |
Output is correct - L = 4 |
9 |
Correct |
76 ms |
6756 KB |
Output is correct - L = 7 |
10 |
Correct |
89 ms |
7248 KB |
Output is correct - L = 4 |
11 |
Correct |
62 ms |
6600 KB |
Output is correct - L = 5 |
12 |
Correct |
194 ms |
17500 KB |
Output is correct - L = 0 |
13 |
Correct |
63 ms |
6708 KB |
Output is correct - L = 10 |
14 |
Correct |
62 ms |
6596 KB |
Output is correct - L = 0 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
62 ms |
6804 KB |
Output isn't correct - Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
62 ms |
6928 KB |
Output isn't correct - Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
62 ms |
6676 KB |
Output isn't correct - Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
63 ms |
7060 KB |
Output isn't correct - Wrong Answer [4] |
2 |
Incorrect |
62 ms |
6804 KB |
Output isn't correct - Wrong Answer [4] |
3 |
Correct |
63 ms |
6824 KB |
Output is correct - L = 4 |
4 |
Incorrect |
62 ms |
6676 KB |
Output isn't correct - Wrong Answer [4] |
5 |
Incorrect |
66 ms |
6784 KB |
Output isn't correct - Wrong Answer [4] |
6 |
Incorrect |
67 ms |
6824 KB |
Output isn't correct - Wrong Answer [9] |
7 |
Correct |
64 ms |
6808 KB |
Output is correct - L = 1 |
8 |
Correct |
65 ms |
6916 KB |
Output is correct - L = 1 |
9 |
Incorrect |
68 ms |
7028 KB |
Output isn't correct - Wrong Answer [9] |
10 |
Incorrect |
61 ms |
6936 KB |
Output isn't correct - Wrong Answer [9] |
11 |
Incorrect |
62 ms |
6928 KB |
Output isn't correct - Wrong Answer [9] |
12 |
Correct |
77 ms |
6928 KB |
Output is correct - L = 0 |
13 |
Correct |
215 ms |
13392 KB |
Output is correct - L = 0 |
14 |
Incorrect |
64 ms |
6820 KB |
Output isn't correct - Wrong Answer [4] |
15 |
Correct |
63 ms |
6880 KB |
Output is correct - L = 12 |
16 |
Correct |
76 ms |
7164 KB |
Output is correct - L = 22 |
17 |
Correct |
84 ms |
6936 KB |
Output is correct - L = 20 |
18 |
Incorrect |
89 ms |
7124 KB |
Output isn't correct - Wrong Answer [9] |
19 |
Incorrect |
65 ms |
6688 KB |
Output isn't correct - Wrong Answer [4] |
20 |
Correct |
74 ms |
7516 KB |
Output is correct - L = 0 |
21 |
Correct |
91 ms |
7528 KB |
Output is correct - L = 0 |
22 |
Incorrect |
61 ms |
6924 KB |
Output isn't correct - Wrong Answer [9] |
23 |
Incorrect |
67 ms |
7044 KB |
Output isn't correct - Wrong Answer [9] |
24 |
Incorrect |
60 ms |
6928 KB |
Output isn't correct - Wrong Answer [9] |