답안 #925549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925549 2024-02-12T03:07:38 Z pan Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
748 ms 4408 KB
#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define input(x) scanf("%d", &x);
#define print(x, y) printf("%d%c", x, y);
using namespace std;
typedef int ll;
typedef pair<ll, ll> pi;
 
ll const INF = 1e9;
vector<ll> adj[30005];
ll where[30005];
int main()
{
	ll n, m, b, p;
	input(n); input(m);
	vector<ll> adj[n];
	ll where[m];
	vector<ll> dist(n, INF);
	for (ll i=0; i<m; ++i) 
	{
		input(b); input(p);
		adj[b].pb(p);
		where[i] = b;
	}
	set<pi> s;
	dist[where[0]] = 0;
	s.insert(mp(0, where[0]));
	while (!s.empty())
	{
		ll c= s.begin()->s;
		s.erase(s.begin());
		for (ll u: adj[c])
		{
			ll jump = 0;
			for (ll x=c+u; x<n; x+=u)
			{
				jump++;
				if (dist[x]>dist[c]+jump)
				{
					if (dist[x]!=INF) s.erase(mp(dist[x], x));
					dist[x] = dist[c]+jump;
					s.insert(mp(dist[x], x));
				}
			}
			jump = 0;
			for (ll x=c-u; x>=0; x-=u)
			{
				jump++;
				if (dist[x]>dist[c]+jump)
				{
					if (dist[x]!=INF) s.erase(mp(dist[x], x));
					dist[x] = dist[c]+jump;
					s.insert(mp(dist[x], x));
				}
			}
		}
	}
	if (dist[where[1]]==INF) {print(-1, '\n');}
	else {print(dist[where[1]], '\n');}
	return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:18:2: note: in expansion of macro 'input'
   18 |  input(n); input(m);
      |  ^~~~~
skyscraper.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:18:12: note: in expansion of macro 'input'
   18 |  input(n); input(m);
      |            ^~~~~
skyscraper.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:24:3: note: in expansion of macro 'input'
   24 |   input(b); input(p);
      |   ^~~~~
skyscraper.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define input(x) scanf("%d", &x);
      |                  ~~~~~^~~~~~~~~~
skyscraper.cpp:24:13: note: in expansion of macro 'input'
   24 |   input(b); input(p);
      |             ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1112 KB Output is correct
11 Correct 1 ms 1112 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 2 ms 1168 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 5 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 2 ms 1116 KB Output is correct
26 Correct 4 ms 1116 KB Output is correct
27 Correct 3 ms 1264 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 3 ms 1116 KB Output is correct
30 Correct 2 ms 1112 KB Output is correct
31 Correct 2 ms 1116 KB Output is correct
32 Correct 2 ms 1116 KB Output is correct
33 Correct 4 ms 1116 KB Output is correct
34 Correct 4 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1112 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 976 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 4 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 4 ms 1120 KB Output is correct
27 Correct 4 ms 1124 KB Output is correct
28 Correct 1 ms 1124 KB Output is correct
29 Correct 3 ms 1308 KB Output is correct
30 Correct 2 ms 1116 KB Output is correct
31 Correct 2 ms 1116 KB Output is correct
32 Correct 1 ms 1124 KB Output is correct
33 Correct 4 ms 1124 KB Output is correct
34 Correct 4 ms 1320 KB Output is correct
35 Correct 6 ms 1380 KB Output is correct
36 Correct 2 ms 1124 KB Output is correct
37 Correct 6 ms 1380 KB Output is correct
38 Correct 7 ms 1380 KB Output is correct
39 Correct 7 ms 1636 KB Output is correct
40 Correct 8 ms 1532 KB Output is correct
41 Correct 8 ms 1380 KB Output is correct
42 Correct 48 ms 1376 KB Output is correct
43 Correct 49 ms 1368 KB Output is correct
44 Correct 50 ms 1368 KB Output is correct
45 Correct 7 ms 1368 KB Output is correct
46 Correct 7 ms 1584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1112 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 4 ms 1112 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 4 ms 1116 KB Output is correct
27 Correct 4 ms 1116 KB Output is correct
28 Correct 1 ms 1184 KB Output is correct
29 Correct 3 ms 1116 KB Output is correct
30 Correct 2 ms 1116 KB Output is correct
31 Correct 3 ms 1112 KB Output is correct
32 Correct 2 ms 1116 KB Output is correct
33 Correct 4 ms 1116 KB Output is correct
34 Correct 4 ms 1112 KB Output is correct
35 Correct 6 ms 1368 KB Output is correct
36 Correct 2 ms 1112 KB Output is correct
37 Correct 6 ms 1372 KB Output is correct
38 Correct 7 ms 1372 KB Output is correct
39 Correct 7 ms 1372 KB Output is correct
40 Correct 7 ms 1628 KB Output is correct
41 Correct 7 ms 1372 KB Output is correct
42 Correct 51 ms 1372 KB Output is correct
43 Correct 49 ms 1368 KB Output is correct
44 Correct 48 ms 1460 KB Output is correct
45 Correct 7 ms 1368 KB Output is correct
46 Correct 7 ms 1372 KB Output is correct
47 Correct 21 ms 2460 KB Output is correct
48 Correct 6 ms 2140 KB Output is correct
49 Correct 6 ms 2140 KB Output is correct
50 Correct 4 ms 2140 KB Output is correct
51 Correct 37 ms 4052 KB Output is correct
52 Correct 37 ms 3676 KB Output is correct
53 Correct 14 ms 3676 KB Output is correct
54 Correct 3 ms 2652 KB Output is correct
55 Correct 3 ms 2648 KB Output is correct
56 Correct 735 ms 4408 KB Output is correct
57 Correct 67 ms 3420 KB Output is correct
58 Correct 706 ms 3032 KB Output is correct
59 Correct 685 ms 2904 KB Output is correct
60 Correct 748 ms 3100 KB Output is correct
61 Correct 617 ms 3136 KB Output is correct
62 Correct 9 ms 3164 KB Output is correct
63 Correct 49 ms 3676 KB Output is correct
64 Correct 56 ms 3928 KB Output is correct
65 Correct 62 ms 3884 KB Output is correct
66 Correct 88 ms 3632 KB Output is correct
67 Correct 82 ms 3672 KB Output is correct