Submission #124074

# Submission time Handle Problem Language Result Execution time Memory
124074 2019-07-02T13:25:48 Z RafikHachana Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
1000 ms 64780 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long

vector<vector<pair<int,int> > > g;
int n,m;

void dijsktra()
{
  vector<int> dist(n,1e9);
  priority_queue<pair<int,int> , vector<pair<int,int> > , greater<pair<int,int> > > q;
  q.push({0,0});
  dist[0] = 0;
  while(!q.empty())
  {
    int d = q.top().first;
    int u = q.top().second;
    q.pop();
    for(auto it:g[u])
    {
      if(dist[it.second]> d + it.first)
      {
        dist[it.second] =  d + it.first;
        q.push({dist[it.second],it.second});
      }
    }
  }
  if(dist[1]==1e9) cout<<-1<<endl;
  else cout<<dist[1]<<endl;
}


main()
{
  cin>>m>>n;
  vector<int> b(n),p(n);
  for(int i=0;i<n;i++)
  {
    cin>>b[i]>>p[i];
  }
  g.resize(n);
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      if(i==j) continue;
      if(b[i]%p[i]==b[j]%p[i]) g[i].push_back({abs(b[j]-b[i])/p[i],j});
    }
  }
  dijsktra();
}

Compilation message

skyscraper.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 12 ms 504 KB Output is correct
11 Correct 116 ms 4852 KB Output is correct
12 Correct 219 ms 64248 KB Output is correct
13 Correct 220 ms 64676 KB Output is correct
14 Correct 113 ms 3392 KB Output is correct
15 Correct 111 ms 3372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 117 ms 4700 KB Output is correct
12 Correct 220 ms 64220 KB Output is correct
13 Correct 223 ms 64632 KB Output is correct
14 Correct 112 ms 3448 KB Output is correct
15 Correct 123 ms 3476 KB Output is correct
16 Correct 22 ms 888 KB Output is correct
17 Correct 87 ms 1776 KB Output is correct
18 Correct 27 ms 504 KB Output is correct
19 Correct 10 ms 376 KB Output is correct
20 Correct 227 ms 64632 KB Output is correct
21 Correct 37 ms 504 KB Output is correct
22 Correct 16 ms 376 KB Output is correct
23 Correct 26 ms 504 KB Output is correct
24 Correct 93 ms 812 KB Output is correct
25 Correct 103 ms 892 KB Output is correct
26 Correct 212 ms 58616 KB Output is correct
27 Correct 215 ms 60412 KB Output is correct
28 Correct 104 ms 856 KB Output is correct
29 Correct 18 ms 1016 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 12 ms 632 KB Output is correct
32 Correct 9 ms 504 KB Output is correct
33 Correct 112 ms 3452 KB Output is correct
34 Correct 112 ms 3448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 296 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 115 ms 4700 KB Output is correct
12 Correct 225 ms 64312 KB Output is correct
13 Correct 222 ms 64744 KB Output is correct
14 Correct 112 ms 3404 KB Output is correct
15 Correct 112 ms 3320 KB Output is correct
16 Correct 22 ms 888 KB Output is correct
17 Correct 86 ms 1672 KB Output is correct
18 Correct 28 ms 504 KB Output is correct
19 Correct 10 ms 376 KB Output is correct
20 Correct 224 ms 64780 KB Output is correct
21 Correct 37 ms 504 KB Output is correct
22 Correct 15 ms 376 KB Output is correct
23 Correct 26 ms 504 KB Output is correct
24 Correct 94 ms 760 KB Output is correct
25 Correct 103 ms 804 KB Output is correct
26 Correct 210 ms 58828 KB Output is correct
27 Correct 214 ms 60380 KB Output is correct
28 Correct 104 ms 888 KB Output is correct
29 Correct 18 ms 1016 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 12 ms 632 KB Output is correct
32 Correct 9 ms 504 KB Output is correct
33 Correct 112 ms 3324 KB Output is correct
34 Correct 112 ms 3444 KB Output is correct
35 Execution timed out 1080 ms 5284 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 115 ms 4828 KB Output is correct
12 Correct 220 ms 64248 KB Output is correct
13 Correct 221 ms 64724 KB Output is correct
14 Correct 113 ms 3448 KB Output is correct
15 Correct 111 ms 3428 KB Output is correct
16 Correct 22 ms 888 KB Output is correct
17 Correct 85 ms 1784 KB Output is correct
18 Correct 27 ms 476 KB Output is correct
19 Correct 10 ms 376 KB Output is correct
20 Correct 222 ms 64632 KB Output is correct
21 Correct 37 ms 504 KB Output is correct
22 Correct 15 ms 376 KB Output is correct
23 Correct 26 ms 504 KB Output is correct
24 Correct 93 ms 828 KB Output is correct
25 Correct 104 ms 772 KB Output is correct
26 Correct 210 ms 58616 KB Output is correct
27 Correct 215 ms 60536 KB Output is correct
28 Correct 104 ms 888 KB Output is correct
29 Correct 18 ms 892 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 12 ms 632 KB Output is correct
32 Correct 9 ms 504 KB Output is correct
33 Correct 114 ms 3448 KB Output is correct
34 Correct 112 ms 3448 KB Output is correct
35 Execution timed out 1065 ms 4768 KB Time limit exceeded
36 Halted 0 ms 0 KB -