Submission #611877

# Submission time Handle Problem Language Result Execution time Memory
611877 2022-07-29T08:16:22 Z Hanksburger Sky Walking (IOI19_walk) C++17
10 / 100
1377 ms 540524 KB
#include "walk.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > adj[2000005], tor[100005];
vector<pair<pair<int, int>, int> > vec;
priority_queue<pair<int, int> > pq;
map<pair<int, int>, int> mp;
long long dist[2000005];
set<pair<int, int> > s;
bool visited[2000005];
long long min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int a, int b)
{
	int n=x.size(), m=y.size(), ind=0, cnt=0;
    for (int i=0; i<m; i++)
    {
        vec.push_back({{l[i], 0}, i});
        vec.push_back({{r[i], 1}, i});
    }
    sort(vec.begin(), vec.end());
    for (int i=0; i<n; i++)
    {
        while (ind!=m*2 && vec[ind].first<=make_pair(i, 0))
        {
            if (vec[ind].first.second)
            {
                s.erase({y[vec[ind].second], vec[ind].second});
//                cout << "s erase " << y[vec[ind].second] << ' ' << vec[ind].second << '\n';
            }
            else
            {
                s.insert({y[vec[ind].second], vec[ind].second});
//                cout << "s insert " << y[vec[ind].second] << ' ' << vec[ind].second << '\n';
            }
            ind++;
        }
        mp[{x[i], 0}]=(++cnt);
//        cout << "mp " << x[i] << ' ' << 0 << ' ' << cnt << '\n';
        int pre=0;
        for (auto itr=s.begin(); itr!=s.end(); itr++)
        {
            int fi=itr->first, se=itr->second;
            if (fi>h[i])
                break;
            tor[se].push_back({x[i], fi});
            if (!mp[{x[i], fi}])
            {
                mp[{x[i], fi}]=(++cnt);
//                cout << "mp " << x[i] << ' ' << fi << ' ' << cnt << '\n';
                adj[cnt-1].push_back({cnt, fi-pre});
                adj[cnt].push_back({cnt-1, fi-pre});
                pre=fi;
            }
        }
    }
    for (int j=0; j<m; j++)
    {
        for (int k=1; k<tor[j].size(); k++)
        {
            int u=mp[tor[j][k-1]], v=mp[tor[j][k]], w=tor[j][k].first-tor[j][k-1].first;
            adj[u].push_back({v, w});
            adj[v].push_back({u, w});
        }
    }
    a=mp[{x[a], 0}];
    b=mp[{x[b], 0}];
    for (int i=1; i<=cnt; i++)
        dist[i]=1e18;
    dist[a]=0;
    pq.push({0, a});
    while (!pq.empty())
    {
        int u=pq.top().second;
        pq.pop();
        if (visited[u])
            continue;
        visited[u]=1;
        for (int i=0; i<adj[u].size(); i++)
        {
            int v=adj[u][i].first, w=adj[u][i].second;
            if (dist[u]+w<dist[v])
            {
                dist[v]=dist[u]+w;
                pq.push({-dist[v], v});
            }
        }
    }
    return dist[b]==1e18?-1:dist[b];
}

Compilation message

walk.cpp: In function 'long long int min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:57:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for (int k=1; k<tor[j].size(); k++)
      |                       ~^~~~~~~~~~~~~~
walk.cpp:77:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |         for (int i=0; i<adj[u].size(); i++)
      |                       ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 26 ms 49620 KB Output is correct
2 Correct 30 ms 49572 KB Output is correct
3 Correct 25 ms 49620 KB Output is correct
4 Correct 28 ms 49620 KB Output is correct
5 Correct 31 ms 49612 KB Output is correct
6 Correct 28 ms 49620 KB Output is correct
7 Correct 26 ms 49668 KB Output is correct
8 Correct 25 ms 49684 KB Output is correct
9 Correct 26 ms 49624 KB Output is correct
10 Correct 27 ms 49696 KB Output is correct
11 Correct 30 ms 49664 KB Output is correct
12 Correct 31 ms 49612 KB Output is correct
13 Correct 26 ms 49644 KB Output is correct
14 Correct 30 ms 49624 KB Output is correct
15 Correct 27 ms 49580 KB Output is correct
16 Correct 25 ms 49636 KB Output is correct
17 Correct 27 ms 49768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 49596 KB Output is correct
2 Correct 25 ms 49620 KB Output is correct
3 Correct 1377 ms 164816 KB Output is correct
4 Incorrect 1092 ms 176296 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 144 ms 64000 KB Output is correct
2 Runtime error 1199 ms 540524 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 144 ms 64000 KB Output is correct
2 Runtime error 1199 ms 540524 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 49620 KB Output is correct
2 Correct 30 ms 49572 KB Output is correct
3 Correct 25 ms 49620 KB Output is correct
4 Correct 28 ms 49620 KB Output is correct
5 Correct 31 ms 49612 KB Output is correct
6 Correct 28 ms 49620 KB Output is correct
7 Correct 26 ms 49668 KB Output is correct
8 Correct 25 ms 49684 KB Output is correct
9 Correct 26 ms 49624 KB Output is correct
10 Correct 27 ms 49696 KB Output is correct
11 Correct 30 ms 49664 KB Output is correct
12 Correct 31 ms 49612 KB Output is correct
13 Correct 26 ms 49644 KB Output is correct
14 Correct 30 ms 49624 KB Output is correct
15 Correct 27 ms 49580 KB Output is correct
16 Correct 25 ms 49636 KB Output is correct
17 Correct 27 ms 49768 KB Output is correct
18 Correct 29 ms 49596 KB Output is correct
19 Correct 25 ms 49620 KB Output is correct
20 Correct 1377 ms 164816 KB Output is correct
21 Incorrect 1092 ms 176296 KB Output isn't correct
22 Halted 0 ms 0 KB -