結果
| 問題 |
No.1898 Battle and Exchange
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2022-04-08 22:18:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 649 ms / 5,000 ms |
| コード長 | 1,533 bytes |
| コンパイル時間 | 3,979 ms |
| コンパイル使用メモリ | 260,744 KB |
| 最終ジャッジ日時 | 2025-01-28 16:17:17 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 58 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d %d",&u,&v);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:26:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | rep(i,n)scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001
int main(){
int n,m;
cin>>n>>m;
vector<vector<int>> E(n);
rep(i,m){
int u,v;
scanf("%d %d",&u,&v);
u--,v--;
E[u].push_back(v);
E[v].push_back(u);
}
vector<long long> a(n),b(n),c(n);
rep(i,n)scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
long long ok = Inf,ng = a[0]+b[0]+c[0];
while(ok-ng>1){
int mid =(ok+ng)/2;
// cout<<mid<<endl;
{
bool f = false;
rep(i,E[0].size()){
int to = E[0][i];
if(a[to]+b[to]+c[to] < mid - 1 + max({a[0],b[0],c[0]})){
f = true;
break;
}
}
if(!f){
ng = mid;
continue;
}
}
//cout<<mid<<endl;
vector<bool> f(n,false);
f[0] = true;
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q;
Q.emplace(0,0);
vector<int> t(3,1);
t[0] = mid-2;
while(Q.size()>0){
int D = Q.top().first;
int u = Q.top().second;
if(D >= t[0]+t[1]+t[2])break;
Q.pop();
t.push_back(a[u]);
t.push_back(b[u]);
t.push_back(c[u]);
sort(t.rbegin(),t.rend());
rep(i,3)t.pop_back();
rep(i,E[u].size()){
int v = E[u][i];
if(f[v])continue;
f[v] = true;
Q.emplace(a[v] + b[v] + c[v],v);
}
}
while(Q.size()>0){
int u = Q.top().second;
f[u]= false;
Q.pop();
}
if(f[n-1])ok = mid;
else ng = mid;
}
cout<<1<<' '<<1<<' '<<ok-2<<endl;
return 0;
}
沙耶花