Submission #393796

# Submission time Handle Problem Language Result Execution time Memory
393796 2021-04-24T13:38:50 Z loctildore Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 35504 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define x first
#define y second
#define elif else if
#define endl '\n'
#define all(x) begin(x), end(x)
#define k 100
template <typename T>
ostream& operator << (ostream& os, const vector<T>& a) {
    os << '[';
    bool E = false;
    for(const T& x : a) {
        if(E) os << ' ';
        os << x;
        E = true;
    }
    return os << ']';
}
int n,m;
int b[30069],p[30069];
bool done[30069];
set<pair<int,int>> st;
vector<int> grph[30069];
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin>>n>>m;
  for (int i = 0; i < m; i++) {
    cin>>b[i]>>p[i];
    grph[b[i]].push_back(p[i]);
  }
  pq.push({0,b[0]});
  while (pq.size()) {
    auto temp=pq.top();
    pq.pop();
    if (done[temp.s]) {
      continue;
    }
    done[temp.s]=true;
    if (temp.s==b[1]) {
      cout<<temp.f<<endl;
      return 0;
    }
    for (int i:grph[temp.s]) {
      if (st.find({temp.s%i,i})!=st.end()) {
        continue;
      }
      st.insert({temp.s%i,i});
      for (int j = temp.s%i; j < n; j+=i) {
        pq.push({temp.f+abs(j-temp.s)/i,j});
      }
    }
  }
  cout<<-1<<endl;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1032 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 1028 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 1 ms 1036 KB Output is correct
10 Correct 1 ms 972 KB Output is correct
11 Correct 1 ms 972 KB Output is correct
12 Correct 1 ms 972 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 3 ms 1168 KB Output is correct
15 Correct 2 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 1 ms 1032 KB Output is correct
10 Correct 1 ms 972 KB Output is correct
11 Correct 1 ms 972 KB Output is correct
12 Correct 1 ms 972 KB Output is correct
13 Correct 1 ms 1040 KB Output is correct
14 Correct 3 ms 1100 KB Output is correct
15 Correct 2 ms 1100 KB Output is correct
16 Correct 1 ms 1032 KB Output is correct
17 Correct 2 ms 1228 KB Output is correct
18 Correct 1 ms 972 KB Output is correct
19 Correct 1 ms 972 KB Output is correct
20 Correct 2 ms 1176 KB Output is correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 1 ms 972 KB Output is correct
23 Correct 2 ms 1040 KB Output is correct
24 Correct 3 ms 1240 KB Output is correct
25 Correct 2 ms 1100 KB Output is correct
26 Correct 2 ms 1100 KB Output is correct
27 Correct 2 ms 1100 KB Output is correct
28 Correct 3 ms 1228 KB Output is correct
29 Correct 11 ms 1620 KB Output is correct
30 Correct 4 ms 1228 KB Output is correct
31 Correct 6 ms 1372 KB Output is correct
32 Correct 5 ms 1228 KB Output is correct
33 Correct 23 ms 2252 KB Output is correct
34 Correct 15 ms 2196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 1036 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 1028 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 1036 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 972 KB Output is correct
12 Correct 1 ms 972 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 3 ms 1100 KB Output is correct
15 Correct 2 ms 1100 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 3 ms 1228 KB Output is correct
18 Correct 1 ms 1036 KB Output is correct
19 Correct 1 ms 972 KB Output is correct
20 Correct 2 ms 1100 KB Output is correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 1 ms 972 KB Output is correct
23 Correct 2 ms 1100 KB Output is correct
24 Correct 3 ms 1228 KB Output is correct
25 Correct 2 ms 1100 KB Output is correct
26 Correct 2 ms 1100 KB Output is correct
27 Correct 2 ms 1100 KB Output is correct
28 Correct 3 ms 1172 KB Output is correct
29 Correct 11 ms 1620 KB Output is correct
30 Correct 4 ms 1228 KB Output is correct
31 Correct 8 ms 1372 KB Output is correct
32 Correct 5 ms 1228 KB Output is correct
33 Correct 23 ms 2208 KB Output is correct
34 Correct 15 ms 2252 KB Output is correct
35 Correct 22 ms 3212 KB Output is correct
36 Correct 3 ms 1228 KB Output is correct
37 Correct 16 ms 2792 KB Output is correct
38 Correct 14 ms 2504 KB Output is correct
39 Correct 7 ms 1740 KB Output is correct
40 Correct 8 ms 1740 KB Output is correct
41 Correct 10 ms 2124 KB Output is correct
42 Correct 6 ms 1612 KB Output is correct
43 Correct 6 ms 1680 KB Output is correct
44 Correct 6 ms 1616 KB Output is correct
45 Correct 108 ms 6460 KB Output is correct
46 Correct 74 ms 6496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 2 ms 972 KB Output is correct
11 Correct 1 ms 972 KB Output is correct
12 Correct 1 ms 972 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 3 ms 1100 KB Output is correct
15 Correct 2 ms 1148 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 2 ms 1228 KB Output is correct
18 Correct 1 ms 972 KB Output is correct
19 Correct 1 ms 972 KB Output is correct
20 Correct 2 ms 1100 KB Output is correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 1 ms 1040 KB Output is correct
23 Correct 2 ms 1100 KB Output is correct
24 Correct 4 ms 1228 KB Output is correct
25 Correct 2 ms 1100 KB Output is correct
26 Correct 2 ms 1100 KB Output is correct
27 Correct 2 ms 1100 KB Output is correct
28 Correct 3 ms 1228 KB Output is correct
29 Correct 11 ms 1620 KB Output is correct
30 Correct 3 ms 1228 KB Output is correct
31 Correct 6 ms 1372 KB Output is correct
32 Correct 5 ms 1292 KB Output is correct
33 Correct 23 ms 2252 KB Output is correct
34 Correct 15 ms 2252 KB Output is correct
35 Correct 21 ms 3132 KB Output is correct
36 Correct 3 ms 1168 KB Output is correct
37 Correct 15 ms 2748 KB Output is correct
38 Correct 13 ms 2448 KB Output is correct
39 Correct 8 ms 1612 KB Output is correct
40 Correct 8 ms 1784 KB Output is correct
41 Correct 10 ms 2144 KB Output is correct
42 Correct 6 ms 1612 KB Output is correct
43 Correct 7 ms 1684 KB Output is correct
44 Correct 6 ms 1612 KB Output is correct
45 Correct 109 ms 6552 KB Output is correct
46 Correct 73 ms 6524 KB Output is correct
47 Correct 25 ms 6196 KB Output is correct
48 Correct 8 ms 1792 KB Output is correct
49 Correct 7 ms 1740 KB Output is correct
50 Correct 5 ms 1616 KB Output is correct
51 Correct 33 ms 4716 KB Output is correct
52 Correct 34 ms 4492 KB Output is correct
53 Correct 12 ms 2124 KB Output is correct
54 Correct 3 ms 1228 KB Output is correct
55 Correct 4 ms 1288 KB Output is correct
56 Correct 12 ms 2580 KB Output is correct
57 Correct 4 ms 2244 KB Output is correct
58 Correct 12 ms 2232 KB Output is correct
59 Correct 11 ms 1740 KB Output is correct
60 Correct 11 ms 1740 KB Output is correct
61 Correct 11 ms 1724 KB Output is correct
62 Correct 44 ms 3872 KB Output is correct
63 Correct 517 ms 10476 KB Output is correct
64 Correct 658 ms 10672 KB Output is correct
65 Execution timed out 1089 ms 35504 KB Time limit exceeded
66 Halted 0 ms 0 KB -