답안 #724746

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724746 2023-04-15T20:49:05 Z tigar Jakarta Skyscrapers (APIO15_skyscraper) C++14
0 / 100
2 ms 1980 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
ll b[30030], p[30030];
vector<int>srapers[30030];
vector<pair<int, int> >graff[30030];
ll dist[30030];
bool check1[30030];
ll INF=LONG_LONG_MAX;

void dijkstra(ll cvor)
{
    for(int i=0; i<30030; i++){check1[i]=false; dist[i]=INF;}
    priority_queue<pair<ll, ll> >ord;
    dist[cvor]=0;
    ord.push({0, cvor});
    while(!ord.empty())
    {
        int cv=ord.top().second;
        ord.pop();
        if(check1[cv])continue;
        check1[cv]=true;
        for(int j=0; j<graff[cv].size(); j++)
        {
            ll pp=graff[cv][j].first;
            dist[pp]=min(dist[pp], dist[cv]+graff[cv][j].second);
            if(!check1[pp])ord.push({-dist[pp], pp});
        }
    }
}

int main()
{
    ll m, n;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>b[i]>>p[i];
        srapers[b[i]].push_back(i);
    }
    for(int i=0; i<m; i++)
    {
        int br=1;
        bool ch=false;
        while(b[i]-br*p[i]>=0 or b[i]+br*p[i]<n)
        {
            int j;
            if(b[i]-br*p[i]>=0){j=b[i]-br*p[i];
            for(int l=0; l<srapers[j].size(); l++)
            {
                graff[i].push_back({srapers[j][l], br});
                //graff[srapers[j][l]].push_back({i, br});
            }}
            if(b[i]+br*p[i]<n){j=b[i]+br*p[i];
            for(int l=0; l<srapers[j].size(); l++)
            {
                graff[i].push_back({srapers[j][l], br});
                //graff[srapers[j][l]].push_back({i, br});
            }}
            br++;
        }
    }
   /*/ for(int i=0; i<m; i++)
    {
        cout<<i<<endl;
        for(int j=0; j<graff[i].size(); j++)
        {
            cout<<graff[i][j].first<<" "<<graff[i][j].second<<endl;
        }
        cout<<endl;
    }*/
    dijkstra(0);
    cout<<dist[1];
    return 0;
}

Compilation message

skyscraper.cpp: In function 'void dijkstra(ll)':
skyscraper.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int j=0; j<graff[cv].size(); j++)
      |                      ~^~~~~~~~~~~~~~~~~
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:50:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |             for(int l=0; l<srapers[j].size(); l++)
      |                          ~^~~~~~~~~~~~~~~~~~
skyscraper.cpp:56:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |             for(int l=0; l<srapers[j].size(); l++)
      |                          ~^~~~~~~~~~~~~~~~~~
skyscraper.cpp:45:14: warning: unused variable 'ch' [-Wunused-variable]
   45 |         bool ch=false;
      |              ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1980 KB Output is correct
2 Incorrect 1 ms 1972 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Incorrect 1 ms 1876 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1980 KB Output is correct
2 Incorrect 1 ms 1876 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Incorrect 2 ms 1972 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Incorrect 2 ms 1868 KB Output isn't correct
3 Halted 0 ms 0 KB -