| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1348305 | msb.83 | Currents (EGOI25_currents) | C++20 | 79 ms | 242588 KiB |
//Rahman ve Rahim olan Allah'ın adıyla
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define mid (st+end)/2
using namespace std;
const int INF=1e18+5;
const int ONE=1;
vector<int>bounds(1);
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(0);
freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
int n,m,a,b;cin>>n>>m;vector<vector<int>>adj(n);vector<vector<int>>adjr(n);
for(int i=0;i<m;i++){cin>>a>>b;adj[a].pb(b);adjr[b].pb(a);}
vector<int>deps(n,-1);queue<int>q;q.push(0);deps[0]=0;
while(!q.empty()){
if(!deps[q.front()]==-1){q.pop();continue;}
int nd=q.front();q.pop();
for(auto it:adj[nd]){
if(deps[it]!=-1) continue;
deps[it]=deps[nd]+1;q.push(it);
}
}
vector<int>res(n,INF);priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;vector<bool>vis(n);vis[n-1]=true;
for(auto it:adjr[n-1]){
res[it]=max(deps[it],ONE);pq.push({res[it],it});
}while(!pq.empty()){if(vis[pq.top().se]){pq.pop();continue;}
int nd=pq.top().se,dep=pq.top().fi;pq.pop();vis[nd]=true;
for(auto it:adjr[nd]){
if(vis[it]) continue;
if(res[it]>res[nd]+1){
res[it]=res[nd]+1;pq.push({res[it],it});
}
}
}
for(int i=0;i<n-1;i++){
cout<<res[i]<<" ";
}
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
