Submission #552617

# Submission time Handle Problem Language Result Execution time Memory
552617 2022-04-23T12:30:43 Z QwertyPi Jakarta Skyscrapers (APIO15_skyscraper) C++14
22 / 100
8 ms 1876 KB
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int dp[30001];
vector<int> G[30001];
int A[30001][2];
bool ok[30001][800][2];
int main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < k; i++){
		cin >> A[i][0] >> A[i][1];
		G[A[i][0]].push_back(A[i][1]);
	}
	priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> q;
	q.push({0, A[0][0], 1 << 30});
	fill(dp, dp + n, 1 << 30);
	while(q.size()){
		tuple<int, int, int> qe = q.top(); q.pop();
		int w = get<0>(qe), v = get<1>(qe), ban = get<2>(qe);
		if(dp[v] != (1 << 30)) continue;
		dp[v] = w;
		// cout << v << ' ' << w << endl;
		for(auto i : G[v]){
			if(i % ban == 0) continue;
			for(int j = v % i; j < n; j += i){
				int d = abs(v - j) / i;
				if(dp[j] > w + d) q.push({w + d, j, i});
			}
		}
	}
	cout << (dp[A[1][0]] == (1 << 30) ? -1 : dp[A[1][0]]) << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 2 ms 1108 KB Output is correct
12 Correct 7 ms 1876 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 2 ms 1108 KB Output is correct
15 Correct 2 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 2 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 2 ms 1108 KB Output is correct
12 Correct 7 ms 1876 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 2 ms 1108 KB Output is correct
15 Correct 2 ms 1108 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 3 ms 1300 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 980 KB Output is correct
20 Correct 2 ms 1108 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 2 ms 980 KB Output is correct
24 Correct 3 ms 1108 KB Output is correct
25 Incorrect 2 ms 1108 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 964 KB Output is correct
11 Correct 2 ms 1108 KB Output is correct
12 Correct 8 ms 1876 KB Output is correct
13 Correct 2 ms 980 KB Output is correct
14 Correct 2 ms 1108 KB Output is correct
15 Correct 2 ms 1108 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 5 ms 1300 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 980 KB Output is correct
20 Correct 2 ms 1108 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 2 ms 980 KB Output is correct
24 Correct 3 ms 1108 KB Output is correct
25 Incorrect 2 ms 1108 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 912 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 2 ms 1108 KB Output is correct
12 Correct 7 ms 1876 KB Output is correct
13 Correct 2 ms 980 KB Output is correct
14 Correct 2 ms 1108 KB Output is correct
15 Correct 2 ms 1108 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 5 ms 1300 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 2 ms 1108 KB Output is correct
21 Correct 2 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 2 ms 980 KB Output is correct
24 Correct 2 ms 1108 KB Output is correct
25 Incorrect 2 ms 1108 KB Output isn't correct
26 Halted 0 ms 0 KB -