답안 #43928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43928 2018-03-28T09:54:47 Z Kerim Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 13024 KB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int arr[MAXN],dis[MAXN];
vector<int>adj[MAXN];
int main(){
    //~ freopen("file.in", "r", stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		adj[u].pb(v);arr[i]=u;
	}
	priority_queue<pair<int,int> >q;
	q.push(mp(0,arr[1]));
	for(int i=0;i<n;i++)
		dis[i]=INF;
		dis[arr[1]]=0;
	while(!q.empty()){
		int val=-q.top().ff;
		int nd=q.top().ss;
		q.pop();
		if(dis[nd]!=val)
			continue;
		tr(it,adj[nd]){
			int cost=*it;
			for(int i=1;;i++){
				if(nd-cost*i<0 and nd+cost*i>=n)
					break;
				if(nd-cost*i>=0 and umin(dis[nd-cost*i],dis[nd]+i))
					q.push(mp(-dis[nd-cost*i],nd-cost*i));
				if(nd+cost*i<n and umin(dis[nd+cost*i],dis[nd]+i))
					q.push(mp(-dis[nd+cost*i],nd+cost*i));	
			}
		}	
	}
	if(dis[arr[2]]==INF)
		dis[arr[2]]=-1;
	printf("%d\n",dis[arr[2]]);
	return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:33:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i=0;i<n;i++)
  ^~~
skyscraper.cpp:35:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   dis[arr[1]]=0;
   ^~~
skyscraper.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
skyscraper.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&u,&v);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 3 ms 2792 KB Output is correct
3 Correct 3 ms 2792 KB Output is correct
4 Correct 3 ms 2792 KB Output is correct
5 Correct 3 ms 2812 KB Output is correct
6 Correct 3 ms 2852 KB Output is correct
7 Correct 3 ms 2852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2852 KB Output is correct
2 Correct 3 ms 2880 KB Output is correct
3 Correct 3 ms 2880 KB Output is correct
4 Correct 3 ms 2880 KB Output is correct
5 Correct 3 ms 2880 KB Output is correct
6 Correct 3 ms 2896 KB Output is correct
7 Correct 3 ms 2896 KB Output is correct
8 Correct 3 ms 2896 KB Output is correct
9 Correct 3 ms 2896 KB Output is correct
10 Correct 4 ms 2932 KB Output is correct
11 Correct 5 ms 2968 KB Output is correct
12 Correct 4 ms 2980 KB Output is correct
13 Correct 4 ms 3008 KB Output is correct
14 Correct 4 ms 3040 KB Output is correct
15 Correct 4 ms 3208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3236 KB Output is correct
2 Correct 3 ms 3280 KB Output is correct
3 Correct 3 ms 3280 KB Output is correct
4 Correct 4 ms 3280 KB Output is correct
5 Correct 3 ms 3280 KB Output is correct
6 Correct 3 ms 3280 KB Output is correct
7 Correct 4 ms 3284 KB Output is correct
8 Correct 3 ms 3376 KB Output is correct
9 Correct 3 ms 3376 KB Output is correct
10 Correct 4 ms 3376 KB Output is correct
11 Correct 4 ms 3376 KB Output is correct
12 Correct 4 ms 3376 KB Output is correct
13 Correct 4 ms 3376 KB Output is correct
14 Correct 4 ms 3376 KB Output is correct
15 Correct 4 ms 3376 KB Output is correct
16 Correct 4 ms 3376 KB Output is correct
17 Correct 5 ms 3376 KB Output is correct
18 Correct 4 ms 3388 KB Output is correct
19 Correct 4 ms 3400 KB Output is correct
20 Correct 9 ms 3536 KB Output is correct
21 Correct 4 ms 3536 KB Output is correct
22 Correct 4 ms 3536 KB Output is correct
23 Correct 4 ms 3536 KB Output is correct
24 Correct 5 ms 3588 KB Output is correct
25 Correct 5 ms 3608 KB Output is correct
26 Correct 9 ms 3608 KB Output is correct
27 Correct 8 ms 3608 KB Output is correct
28 Correct 4 ms 3660 KB Output is correct
29 Correct 6 ms 3680 KB Output is correct
30 Correct 4 ms 3688 KB Output is correct
31 Correct 4 ms 3692 KB Output is correct
32 Correct 4 ms 3696 KB Output is correct
33 Correct 5 ms 3700 KB Output is correct
34 Correct 7 ms 3888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3888 KB Output is correct
2 Correct 3 ms 3888 KB Output is correct
3 Correct 3 ms 3888 KB Output is correct
4 Correct 3 ms 3888 KB Output is correct
5 Correct 3 ms 3888 KB Output is correct
6 Correct 4 ms 3888 KB Output is correct
7 Correct 3 ms 3888 KB Output is correct
8 Correct 3 ms 3888 KB Output is correct
9 Correct 3 ms 3888 KB Output is correct
10 Correct 3 ms 3888 KB Output is correct
11 Correct 4 ms 3888 KB Output is correct
12 Correct 4 ms 3888 KB Output is correct
13 Correct 5 ms 3888 KB Output is correct
14 Correct 4 ms 3888 KB Output is correct
15 Correct 4 ms 3888 KB Output is correct
16 Correct 4 ms 3888 KB Output is correct
17 Correct 4 ms 3888 KB Output is correct
18 Correct 5 ms 3888 KB Output is correct
19 Correct 4 ms 3888 KB Output is correct
20 Correct 10 ms 3888 KB Output is correct
21 Correct 4 ms 3888 KB Output is correct
22 Correct 4 ms 3888 KB Output is correct
23 Correct 5 ms 3888 KB Output is correct
24 Correct 5 ms 3888 KB Output is correct
25 Correct 5 ms 3964 KB Output is correct
26 Correct 9 ms 3964 KB Output is correct
27 Correct 8 ms 3964 KB Output is correct
28 Correct 4 ms 3992 KB Output is correct
29 Correct 5 ms 4012 KB Output is correct
30 Correct 4 ms 4020 KB Output is correct
31 Correct 4 ms 4024 KB Output is correct
32 Correct 4 ms 4028 KB Output is correct
33 Correct 5 ms 4032 KB Output is correct
34 Correct 6 ms 4252 KB Output is correct
35 Correct 20 ms 4552 KB Output is correct
36 Correct 6 ms 4552 KB Output is correct
37 Correct 12 ms 4700 KB Output is correct
38 Correct 16 ms 5116 KB Output is correct
39 Correct 15 ms 5380 KB Output is correct
40 Correct 16 ms 5644 KB Output is correct
41 Correct 15 ms 5908 KB Output is correct
42 Correct 79 ms 6028 KB Output is correct
43 Correct 76 ms 6124 KB Output is correct
44 Correct 81 ms 6332 KB Output is correct
45 Correct 18 ms 6668 KB Output is correct
46 Correct 13 ms 7008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7008 KB Output is correct
2 Correct 3 ms 7008 KB Output is correct
3 Correct 3 ms 7008 KB Output is correct
4 Correct 3 ms 7008 KB Output is correct
5 Correct 3 ms 7008 KB Output is correct
6 Correct 3 ms 7008 KB Output is correct
7 Correct 4 ms 7008 KB Output is correct
8 Correct 3 ms 7008 KB Output is correct
9 Correct 4 ms 7008 KB Output is correct
10 Correct 3 ms 7008 KB Output is correct
11 Correct 4 ms 7008 KB Output is correct
12 Correct 4 ms 7008 KB Output is correct
13 Correct 4 ms 7008 KB Output is correct
14 Correct 4 ms 7008 KB Output is correct
15 Correct 5 ms 7008 KB Output is correct
16 Correct 4 ms 7008 KB Output is correct
17 Correct 4 ms 7008 KB Output is correct
18 Correct 5 ms 7008 KB Output is correct
19 Correct 4 ms 7008 KB Output is correct
20 Correct 10 ms 7008 KB Output is correct
21 Correct 4 ms 7008 KB Output is correct
22 Correct 4 ms 7008 KB Output is correct
23 Correct 5 ms 7008 KB Output is correct
24 Correct 5 ms 7008 KB Output is correct
25 Correct 5 ms 7008 KB Output is correct
26 Correct 8 ms 7008 KB Output is correct
27 Correct 8 ms 7008 KB Output is correct
28 Correct 4 ms 7008 KB Output is correct
29 Correct 5 ms 7008 KB Output is correct
30 Correct 4 ms 7008 KB Output is correct
31 Correct 5 ms 7008 KB Output is correct
32 Correct 4 ms 7008 KB Output is correct
33 Correct 6 ms 7008 KB Output is correct
34 Correct 6 ms 7044 KB Output is correct
35 Correct 12 ms 7312 KB Output is correct
36 Correct 5 ms 7312 KB Output is correct
37 Correct 11 ms 7572 KB Output is correct
38 Correct 15 ms 8116 KB Output is correct
39 Correct 15 ms 8132 KB Output is correct
40 Correct 15 ms 8524 KB Output is correct
41 Correct 15 ms 8800 KB Output is correct
42 Correct 80 ms 8808 KB Output is correct
43 Correct 74 ms 9016 KB Output is correct
44 Correct 77 ms 9224 KB Output is correct
45 Correct 12 ms 9564 KB Output is correct
46 Correct 15 ms 9740 KB Output is correct
47 Correct 24 ms 10752 KB Output is correct
48 Correct 12 ms 10752 KB Output is correct
49 Correct 12 ms 10752 KB Output is correct
50 Correct 9 ms 10752 KB Output is correct
51 Correct 41 ms 12516 KB Output is correct
52 Correct 35 ms 12516 KB Output is correct
53 Correct 23 ms 12672 KB Output is correct
54 Correct 5 ms 12672 KB Output is correct
55 Correct 6 ms 12672 KB Output is correct
56 Execution timed out 1070 ms 13024 KB Time limit exceeded
57 Halted 0 ms 0 KB -