結果
| 問題 |
No.3093 Safe Infection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-06 15:49:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 2,000 ms |
| コード長 | 715 bytes |
| コンパイル時間 | 970 ms |
| コンパイル使用メモリ | 84,052 KB |
| 実行使用メモリ | 17,496 KB |
| 最終ジャッジ日時 | 2025-04-06 15:49:16 |
| 合計ジャッジ時間 | 4,841 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 70 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:17: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
27 | for(auto[_,u]:Ai)
| ^
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
#include<atcoder/dsu>
using namespace std;
int N,M,K;
int A[1<<17];
vector<int>G[1<<17];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>M>>K;
for(int i=0;i<N;i++)cin>>A[i];
for(int i=0;i<M;i++)
{
int u,v;cin>>u>>v;u--,v--;
G[u].push_back(v);
G[v].push_back(u);
}
vector<pair<int,int> >Ai(N);
for(int i=0;i<N;i++)Ai[i]=make_pair(A[i],i);
sort(Ai.begin(),Ai.end());
atcoder::dsu uf(N);
vector<int>M(A,A+N);
for(auto[_,u]:Ai)
{
for(int v:G[u])if(A[v]<=A[u])
{
if(M[uf.leader(v)]+K>=A[u])
{
int w=uf.merge(u,v);
M[w]=A[u];
}
}
}
cout<<(uf.groups().size()==1?"Yes":"No")<<endl;
}