답안 #146750

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146750 2019-08-25T22:29:30 Z TadijaSebez 철도 요금 (JOI16_ho_t3) C++11
100 / 100
209 ms 21068 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=200050;
int u[N],v[N],w[N],r[N],ans[N];
bool use[N];
vector<pair<int,int>> E[N];
int dist[N],dp[N],n,m,q;
void BFS()
{
	for(int i=1;i<=n;i++) dist[i]=N,dp[i]=0;
	queue<int> q;
	q.push(1);
	dist[1]=0;dp[1]=::q+1;
	while(q.size())
	{
		int x=q.front();
		q.pop();
		ans[dp[x]]++;
		for(auto e:E[x])
		{
			int y,l;
			tie(y,l)=e;
			if(dist[y]>dist[x]+1)
			{
				dist[y]=dist[x]+1;
				dp[y]=0;
				q.push(y);
			}
			if(dist[y]==dist[x]+1) dp[y]=max(dp[y],min(dp[x],l));
		}
	}
	for(int i=1;i<=::q;i++) ans[i]+=ans[i-1];
}
int main()
{
	scanf("%i %i %i",&n,&m,&q);
	for(int i=1;i<=m;i++) scanf("%i %i",&u[i],&v[i]),w[i]=q+1;
	for(int i=1;i<=q;i++) scanf("%i",&r[i]),use[r[i]]=1,w[r[i]]=i;
	for(int i=1;i<=m;i++) E[u[i]].pb({v[i],w[i]}),E[v[i]].pb({u[i],w[i]});
	BFS();
	for(int i=1;i<=q;i++) printf("%i\n",ans[i]);
	return 0;
}

Compilation message

2016_ho_t3.cpp: In function 'int main()':
2016_ho_t3.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i %i",&n,&m,&q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
2016_ho_t3.cpp:38:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=m;i++) scanf("%i %i",&u[i],&v[i]),w[i]=q+1;
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
2016_ho_t3.cpp:39:53: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=q;i++) scanf("%i",&r[i]),use[r[i]]=1,w[r[i]]=i;
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 7 ms 4984 KB Output is correct
3 Correct 7 ms 5240 KB Output is correct
4 Correct 6 ms 5112 KB Output is correct
5 Correct 7 ms 5112 KB Output is correct
6 Correct 6 ms 5112 KB Output is correct
7 Correct 6 ms 5112 KB Output is correct
8 Correct 7 ms 5112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 7 ms 4984 KB Output is correct
3 Correct 7 ms 5240 KB Output is correct
4 Correct 6 ms 5112 KB Output is correct
5 Correct 7 ms 5112 KB Output is correct
6 Correct 6 ms 5112 KB Output is correct
7 Correct 6 ms 5112 KB Output is correct
8 Correct 7 ms 5112 KB Output is correct
9 Correct 136 ms 17112 KB Output is correct
10 Correct 126 ms 17016 KB Output is correct
11 Correct 119 ms 16632 KB Output is correct
12 Correct 126 ms 16640 KB Output is correct
13 Correct 112 ms 16736 KB Output is correct
14 Correct 116 ms 16604 KB Output is correct
15 Correct 78 ms 12484 KB Output is correct
16 Correct 64 ms 11512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 17116 KB Output is correct
2 Correct 169 ms 17068 KB Output is correct
3 Correct 100 ms 14796 KB Output is correct
4 Correct 112 ms 16760 KB Output is correct
5 Correct 111 ms 16760 KB Output is correct
6 Correct 116 ms 16696 KB Output is correct
7 Correct 70 ms 11640 KB Output is correct
8 Correct 76 ms 11384 KB Output is correct
9 Correct 47 ms 11164 KB Output is correct
10 Correct 46 ms 11112 KB Output is correct
11 Correct 140 ms 17388 KB Output is correct
12 Correct 120 ms 16744 KB Output is correct
13 Correct 127 ms 16448 KB Output is correct
14 Correct 150 ms 17480 KB Output is correct
15 Correct 137 ms 16908 KB Output is correct
16 Correct 141 ms 16640 KB Output is correct
17 Correct 166 ms 17528 KB Output is correct
18 Correct 99 ms 13304 KB Output is correct
19 Correct 197 ms 20728 KB Output is correct
20 Correct 135 ms 17540 KB Output is correct
21 Correct 90 ms 12376 KB Output is correct
22 Correct 86 ms 12408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 7 ms 4984 KB Output is correct
3 Correct 7 ms 5240 KB Output is correct
4 Correct 6 ms 5112 KB Output is correct
5 Correct 7 ms 5112 KB Output is correct
6 Correct 6 ms 5112 KB Output is correct
7 Correct 6 ms 5112 KB Output is correct
8 Correct 7 ms 5112 KB Output is correct
9 Correct 136 ms 17112 KB Output is correct
10 Correct 126 ms 17016 KB Output is correct
11 Correct 119 ms 16632 KB Output is correct
12 Correct 126 ms 16640 KB Output is correct
13 Correct 112 ms 16736 KB Output is correct
14 Correct 116 ms 16604 KB Output is correct
15 Correct 78 ms 12484 KB Output is correct
16 Correct 64 ms 11512 KB Output is correct
17 Correct 122 ms 17116 KB Output is correct
18 Correct 169 ms 17068 KB Output is correct
19 Correct 100 ms 14796 KB Output is correct
20 Correct 112 ms 16760 KB Output is correct
21 Correct 111 ms 16760 KB Output is correct
22 Correct 116 ms 16696 KB Output is correct
23 Correct 70 ms 11640 KB Output is correct
24 Correct 76 ms 11384 KB Output is correct
25 Correct 47 ms 11164 KB Output is correct
26 Correct 46 ms 11112 KB Output is correct
27 Correct 140 ms 17388 KB Output is correct
28 Correct 120 ms 16744 KB Output is correct
29 Correct 127 ms 16448 KB Output is correct
30 Correct 150 ms 17480 KB Output is correct
31 Correct 137 ms 16908 KB Output is correct
32 Correct 141 ms 16640 KB Output is correct
33 Correct 166 ms 17528 KB Output is correct
34 Correct 99 ms 13304 KB Output is correct
35 Correct 197 ms 20728 KB Output is correct
36 Correct 135 ms 17540 KB Output is correct
37 Correct 90 ms 12376 KB Output is correct
38 Correct 86 ms 12408 KB Output is correct
39 Correct 209 ms 20944 KB Output is correct
40 Correct 197 ms 21068 KB Output is correct
41 Correct 125 ms 16692 KB Output is correct
42 Correct 167 ms 20732 KB Output is correct
43 Correct 175 ms 20724 KB Output is correct
44 Correct 174 ms 20736 KB Output is correct
45 Correct 176 ms 20616 KB Output is correct
46 Correct 100 ms 13992 KB Output is correct
47 Correct 105 ms 13404 KB Output is correct
48 Correct 88 ms 13392 KB Output is correct
49 Correct 73 ms 12776 KB Output is correct
50 Correct 65 ms 12780 KB Output is correct
51 Correct 73 ms 13412 KB Output is correct
52 Correct 68 ms 13420 KB Output is correct
53 Correct 63 ms 12644 KB Output is correct
54 Correct 64 ms 12776 KB Output is correct