結果
| 問題 | No.2316 Freight Train |
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2024-01-08 13:02:06 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 423 bytes |
| 記録 | |
| コンパイル時間 | 1,384 ms |
| コンパイル使用メモリ | 215,132 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-07-03 08:59:36 |
| 合計ジャッジ時間 | 6,899 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/dsu>
using namespace std;
int N,Q;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>Q;
atcoder::dsu uf(N);
for(int i=0;i<N;i++)
{
int p;
cin>>p;
p--;
if(p>=0)uf.merge(i,p);
}
while(Q--)
{
int u,v;
cin>>u>>v;
u--,v--;
cout << (uf.same(u,v)?"Yes\n":"No\n");
}
}
nonon