QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#284085 | #5458. Shortest Path Query | bobbilyking | 0 | 2ms | 5792kb | C++17 | 3.0kb | 2023-12-16 05:00:55 | 2023-12-16 05:00:57 |
Judging History
你现在查看的是测评时间为 2023-12-16 05:00:57 的历史记录
- [2024-06-21 12:38:30]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-12-16 05:00:55]
- 提交
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]) {
vector<pl> temp;
// assume opt's are convex hulls in sorted order already
// then we simply need to do a linear merge
ll lp = 0, rp = 0;
auto append = [&](ll x, ll y) {
while (temp.size() and y <= temp.back().V) temp.pop_back();
temp.emplace_back(x, y);
};
while (lp < opt[i].size() and rp < opt[x].size()) {
auto [x1, y1] = opt[i][lp];
x1 += (w==0); y1 += (w==1);
auto [x2, y2] = opt[x][rp];
if (x1 >= x2 and y1 >= y2) { // merge left first
append(x1, y1), lp++;
} else {
append(x2, y2), rp++;
}
}
while (lp < opt[i].size()) {
auto [x1, y1] = opt[i][lp];
x1 += (w==0); y1 += (w==1);
append(x1, y1); lp++;
}
while (rp < opt[x].size()) {
auto [x2, y2] = opt[x][rp];
append(x2, y2), rp++;
}
opt[x] = temp;
if (!--indeg[x]) nq.push_back(x);
}
}
}
}
F(i, 1, n+1) {
// The issue with this pareto front scan is that it's not the
cout << i << ": " << opt[i].size() << endl;
F(j, 1, opt[i].size()) assert(opt[i][j-1].K > opt[i][j].K and opt[i][j-1].V < opt[i][j].V);
}
exit(0);
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';
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 5792kb
input:
4 4 1 2 0 1 3 1 2 4 0 3 4 1 3 3 5 2 3 2 4 2 3 4
output:
1: 1 2: 1 3: 1 4: 2
result:
wrong output format Expected integer, but "1:" found