QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#284082 | #5458. Shortest Path Query | bobbilyking | Compile Error | / | / | C++17 | 2.2kb | 2023-12-16 03:54:45 | 2024-06-21 12:38:29 |
Judging History
你现在查看的是最新测评结果
- [2024-06-21 12:38:29]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-12-16 03:54:45]
- 提交
answer
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
#define FD(i, r, l) for(ll i = r; i > (l); --i)
#define K first
#define V second
#define G(x) ll x; cin >> x;
#define GD(x) ld x; cin >> x;
#define GS(s) string s; cin >> s;
#define EX(x) { cout << x << '\n'; exit(0); }
#define A(a) (a).begin(), (a).end()
#define F(i, l, r) for (ll i = l; i < (r); ++i)
#define NN 50010
#define M 1000000007 // 998244353
vector<pl> opt[NN];
ll indeg[NN];
vector<pl> adj[NN];
int main(){
// freopen("a.in", "r", stdin);
// freopen("a.out", "w", stdout);
ios_base::sync_with_stdio(false); cin.tie(0);
cout << fixed << setprecision(20);
G(n) G(m) while(m--) {
G(u) G(v) G(c)
adj[u].emplace_back(v,c);
indeg[v]++;
}
opt[1] = {pair(0, 0)};
{
vector<ll> q{1}, nq;
for (; q.size(); swap(q, nq), nq.clear()) {
for (auto i: q) {
for (auto [x, w]: adj[i]) {
for (const auto &[a, b]: opt[i]) opt[x].emplace_back(a + (w==0), b + (w==1));
// fix opt[x]
{
sort(A(opt[x]));
vector<pl> temp;
// compute pareto front (should probably reason about this, i ahve shit intuition)
for (auto [x, y]: opt[x]) {
while (temp.size() and y >= temp.back().V) temp.pop_back();
temp.emplace_back(x, y);
}
opt[x] = temp;
}
// idk if this is needed or some more sophisticated merging is needed or some dumb merging is fine
if (!--indeg[x]) nq.push_back(x);
}
}
}
}
G(q) while(q--){
G(a) G(b) G(t)
ll ans = INT_MAX;
for (auto [x, y]: opt[t]) ans = min(ans, x*a + y*b);
cout << ans << '\n';
}
}
詳細信息
In file included from /usr/include/c++/13/string:43, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52, from answer.code:5: /usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int> > >::_Vector_impl::~_Vector_impl()’: /usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::pair<int, int>]’: target specific option mismatch 184 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/13/vector:66, from /usr/include/c++/13/functional:64, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53: /usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here 133 | struct _Vector_impl | ^~~~~~~~~~~~