답안 #452087

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
452087 2021-08-03T18:33:35 Z ZaZo_ Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
358 ms 262148 KB
//Sorry but iam targeting IOI :))
//NEVER LOSE HOPE
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define endl "\n"
#define int long long
#define ceil(a,b)   (a+(b-1))/b
#define all(v) v.begin(),v.end()
#define Hidden ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int mod = 1e9+7;
int32_t main()
{
  //freopen("dprime.in" , "r" , stdin);
  Hidden;
  int n, m;
  cin >> n >> m;
  pair<int,int>arr[n+m];
  vector<pair<int,int>>edges[n+m];
  vector<int>freq[n+m];
  for(int i = 0 ; i < m ; i ++)
  {
    int b , p;
    cin>>b>>p;
    arr[i]={b,p};
    freq[b].push_back(i);
  }
  for(int i = 0 ; i < m ; i++)
  {
    for(int j = arr[i].first+arr[i].second ; j<=n ; j+=arr[i].second)
    {
      for(int p = 0 ; p < freq[j].size() ; p ++)
      {
        edges[arr[i].first].push_back({arr[freq[j][p]].first ,(j-arr[i].first)/arr[i].second});
      }
    }
    for(int j = arr[i].first-arr[i].second ; j>=0 ; j-=arr[i].second)
    {
      for(int p = 0 ; p < freq[j].size() ; p ++)
      {
        edges[arr[i].first].push_back({arr[freq[j][p]].first ,(arr[i].first-j)/arr[i].second});
      }
    }
  }


  priority_queue<pair<int,int>>pq;
  pq.push({0,arr[0].first});
  int dist[30005];
  for(int i = 0 ; i < 30005 ; i++) dist[i]=INT_MAX;
  dist[arr[0].first]=0;
  while(!pq.empty())
  {
    pair<int,int>p=pq.top();
    pq.pop();
    for(int i = 0; i < edges[p.second].size() ; i++)
    {
      int cost=dist[p.second]+edges[p.second][i].second;
      if(dist[edges[p.second][i].first] > cost)
      {
        dist[edges[p.second][i].first] = cost;
        pq.push({-cost , edges[p.second][i].first});
      }
    }
  }
  if(dist[arr[1].first] == INT_MAX) cout<<"-1";
  else cout<<dist[arr[1].first];


}

Compilation message

skyscraper.cpp: In function 'int32_t main()':
skyscraper.cpp:33:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |       for(int p = 0 ; p < freq[j].size() ; p ++)
      |                       ~~^~~~~~~~~~~~~~~~
skyscraper.cpp:40:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |       for(int p = 0 ; p < freq[j].size() ; p ++)
      |                       ~~^~~~~~~~~~~~~~~~
skyscraper.cpp:57:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i = 0; i < edges[p.second].size() ; i++)
      |                    ~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 5 ms 4172 KB Output is correct
12 Correct 2 ms 1352 KB Output is correct
13 Correct 11 ms 7100 KB Output is correct
14 Correct 2 ms 1484 KB Output is correct
15 Correct 2 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 5 ms 4172 KB Output is correct
12 Correct 2 ms 1352 KB Output is correct
13 Correct 13 ms 7100 KB Output is correct
14 Correct 2 ms 1484 KB Output is correct
15 Correct 2 ms 1484 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 3 ms 1740 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 716 KB Output is correct
20 Correct 86 ms 64940 KB Output is correct
21 Correct 1 ms 716 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 2 ms 1100 KB Output is correct
25 Correct 2 ms 972 KB Output is correct
26 Correct 21 ms 9240 KB Output is correct
27 Correct 16 ms 4992 KB Output is correct
28 Correct 2 ms 1228 KB Output is correct
29 Correct 1 ms 844 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 716 KB Output is correct
32 Correct 1 ms 716 KB Output is correct
33 Correct 2 ms 1612 KB Output is correct
34 Correct 3 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 5 ms 4172 KB Output is correct
12 Correct 2 ms 1352 KB Output is correct
13 Correct 10 ms 7100 KB Output is correct
14 Correct 2 ms 1484 KB Output is correct
15 Correct 2 ms 1612 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 4 ms 1740 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 716 KB Output is correct
20 Correct 84 ms 64940 KB Output is correct
21 Correct 1 ms 716 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 2 ms 1100 KB Output is correct
25 Correct 2 ms 972 KB Output is correct
26 Correct 21 ms 9144 KB Output is correct
27 Correct 17 ms 5052 KB Output is correct
28 Correct 2 ms 1228 KB Output is correct
29 Correct 1 ms 844 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 716 KB Output is correct
32 Correct 1 ms 716 KB Output is correct
33 Correct 2 ms 1612 KB Output is correct
34 Correct 3 ms 1612 KB Output is correct
35 Correct 72 ms 48368 KB Output is correct
36 Correct 4 ms 2508 KB Output is correct
37 Correct 88 ms 57608 KB Output is correct
38 Correct 102 ms 66516 KB Output is correct
39 Correct 103 ms 71920 KB Output is correct
40 Correct 105 ms 67936 KB Output is correct
41 Correct 97 ms 64700 KB Output is correct
42 Correct 320 ms 135132 KB Output is correct
43 Correct 266 ms 69116 KB Output is correct
44 Runtime error 358 ms 262148 KB Execution killed with signal 9
45 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 5 ms 4172 KB Output is correct
12 Correct 2 ms 1352 KB Output is correct
13 Correct 11 ms 7076 KB Output is correct
14 Correct 2 ms 1484 KB Output is correct
15 Correct 2 ms 1612 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 3 ms 1740 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 716 KB Output is correct
20 Correct 85 ms 65056 KB Output is correct
21 Correct 1 ms 716 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 2 ms 1100 KB Output is correct
25 Correct 2 ms 972 KB Output is correct
26 Correct 21 ms 9192 KB Output is correct
27 Correct 16 ms 5064 KB Output is correct
28 Correct 2 ms 1228 KB Output is correct
29 Correct 1 ms 844 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 716 KB Output is correct
32 Correct 1 ms 716 KB Output is correct
33 Correct 2 ms 1612 KB Output is correct
34 Correct 3 ms 1612 KB Output is correct
35 Correct 71 ms 48452 KB Output is correct
36 Correct 4 ms 2508 KB Output is correct
37 Correct 87 ms 57676 KB Output is correct
38 Correct 99 ms 66528 KB Output is correct
39 Correct 107 ms 71996 KB Output is correct
40 Correct 100 ms 67800 KB Output is correct
41 Correct 99 ms 64752 KB Output is correct
42 Correct 327 ms 135276 KB Output is correct
43 Correct 264 ms 68992 KB Output is correct
44 Runtime error 358 ms 262148 KB Execution killed with signal 9
45 Halted 0 ms 0 KB -