# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
137086 | 2019-07-27T05:02:31 Z | ksmzzang2003 | 철도 요금 (JOI16_ho_t3) | C++14 | 126 ms | 21760 KB |
#include <bits/stdc++.h> #define maxn 100004 using namespace std; typedef pair <int,int> pii; int N,M,Q,query[maxn],ans[maxn],dp[maxn]; vector <int> adj[maxn]; vector <pii> adj2[maxn]; pii edge[maxn],dist[maxn]; int main() { scanf("%d%d%d",&N,&M,&Q); for(int i=1; i<=M; i++) { int u,v; scanf("%d%d",&u,&v); adj[u].push_back(v); adj[v].push_back(u); edge[i] = pii(u,v); } for(int i=1; i<=Q; i++) { int x; scanf("%d",&x) ; query[x] = i; } for(int i=1; i<=N; i++) dist[i] = pii(-1,i); queue <int> q; dist[1] .first=0 ; q.push(1); while(!q.empty()) { int x = q.front(); q.pop(); for(int next:adj[x]){ if(dist[next].first!=-1) continue; dist[next]. first = dist[x].first +1; q.push(next); } } for(int i=1;i<=M;i++){ pii now = edge[i]; int t = 1987654321; if(query[i]) t=query[i] ; if(dist[now.first].first+1 == dist[now.second].first) adj2[now.second].push_back(pii(now.first,t)); else if(dist[now.second].first+1 == dist[now.first].first) adj2[now.first].push_back(pii(now.second,t)); } sort(dist+1,dist+1+N); dp[1] = 1987654321; for(int i=2;i<=N;i++){ int now = dist[i].second; for(pii next:adj2[now]) dp[now] = max(dp[now],min(dp[next.first],next.second)); if(dp[now]<987654321) ans[dp[now]]++; } for(int i=1;i<=Q;i++) ans[i]+=ans[i-1],printf("%d\n",ans[i]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | Output is correct |
2 | Correct | 6 ms | 4984 KB | Output is correct |
3 | Correct | 7 ms | 5240 KB | Output is correct |
4 | Correct | 7 ms | 4984 KB | Output is correct |
5 | Correct | 7 ms | 5112 KB | Output is correct |
6 | Correct | 8 ms | 5112 KB | Output is correct |
7 | Correct | 6 ms | 5112 KB | Output is correct |
8 | Correct | 6 ms | 5112 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | Output is correct |
2 | Correct | 6 ms | 4984 KB | Output is correct |
3 | Correct | 7 ms | 5240 KB | Output is correct |
4 | Correct | 7 ms | 4984 KB | Output is correct |
5 | Correct | 7 ms | 5112 KB | Output is correct |
6 | Correct | 8 ms | 5112 KB | Output is correct |
7 | Correct | 6 ms | 5112 KB | Output is correct |
8 | Correct | 6 ms | 5112 KB | Output is correct |
9 | Runtime error | 121 ms | 21368 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 126 ms | 21760 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | Output is correct |
2 | Correct | 6 ms | 4984 KB | Output is correct |
3 | Correct | 7 ms | 5240 KB | Output is correct |
4 | Correct | 7 ms | 4984 KB | Output is correct |
5 | Correct | 7 ms | 5112 KB | Output is correct |
6 | Correct | 8 ms | 5112 KB | Output is correct |
7 | Correct | 6 ms | 5112 KB | Output is correct |
8 | Correct | 6 ms | 5112 KB | Output is correct |
9 | Runtime error | 121 ms | 21368 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
10 | Halted | 0 ms | 0 KB | - |