結果
| 問題 | No.3669 误差绝不允许 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-09 15:47:47 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 248 ms / 3,000 ms |
| + 949µs | |
| コード長 | 1,143 bytes |
| 記録 | |
| コンパイル時間 | 7,197 ms |
| コンパイル使用メモリ | 621,096 KB |
| 実行使用メモリ | 25,676 KB |
| 最終ジャッジ日時 | 2026-09-09 15:48:40 |
| 合計ジャッジ時間 | 14,651 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::multiprecision::cpp_int;
using P = pair<cpp_int,int>;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
// L = lcm(1,...,300)
cpp_int L=1;
for(int i=1;i<=300;i++){
L=lcm(L,cpp_int(i));
}
int n,m;
cin>>n>>m;
vector<vector<pair<int,cpp_int>>> G(n);
for(int i=0;i<m;i++){
int u,v,a,b;
cin>>u>>v>>a>>b;
u--;v--;
cpp_int w=cpp_int(a)*(L/b);
G[u].push_back({v,w});
G[v].push_back({u,w});
}
cpp_int INF=L*cpp_int(1000000000LL);
vector<cpp_int> D(n,INF);
priority_queue<P,vector<P>,greater<P>> pq;
D[0]=0;
pq.push({0,0});
while(!pq.empty()){
auto [d,v]=pq.top();
pq.pop();
if(d!=D[v]) continue;
for(auto [to,w]:G[v]){
cpp_int nd=d+w;
if(nd<D[to]){
D[to]=nd;
pq.push({nd,to});
}
}
}
for(int i=1;i<n;i++){
cpp_int g=gcd(D[i],L);
cout<<D[i]/g<<" "<<L/g<<'\n';
}
}