Submission #132816

# Submission time Handle Problem Language Result Execution time Memory
132816 2019-07-19T16:34:35 Z MvC Jakarta Skyscrapers (APIO15_skyscraper) C++11
100 / 100
271 ms 79708 KB
#include <bits/stdc++.h>
#define fi first
#define se second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef unordered_set<int> uset;
 
const int inf = numeric_limits<int>::max();
const int P = 30005;
 
bitset<P>vis[P];
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vi b(m), p(m), dist(n, inf);
    set<pii> cnt;
 
    vvi doge(P);
    vector<vector<pii>> pos(n);
 
    for(int i = 0; i < m; i++){
        cin >> b[i] >> p[i];
        if(cnt.count({b[i], p[i]})) continue;
        doge[p[i]].push_back(b[i]);
        cnt.insert({b[i], p[i]});
        vis[p[i]][b[i]]=1;
    }
 
    for(int i = 0; i < P; i++)
        sort(doge[i].begin(), doge[i].end());
    
    for(int i = 0; i < n; i++)
        for(int j = 0; j < doge[i].size(); j++)
            pos[doge[i][j]].push_back({i, j});
 
    dist[b[0]] = 0;
    set<pii> s;
    s.insert({0, b[0]});
 
    while(!s.empty()){
        int curr = s.begin()->se;
        s.erase(s.begin());
 
        for(auto id : pos[curr]){
            int hi, lo;
            hi = n - 1; // (id.se == doge[id.fi].size() - 1) ? n - 1 : doge[id.fi][id.se + 1];
            lo = 0; // (id.se == 0) ? 0 : doge[id.fi][id.se - 1];
 
            for(int i = curr, j = 0; i <= hi; i += id.fi, j++){
                if(dist[i] > dist[curr] + j){
                    s.erase({dist[i], i});
                    dist[i] = dist[curr] + j;
                    s.insert({dist[i], i});
                }
                if(i != curr && vis[id.fi][i]) break;
            }
 
            for(int i = curr, j = 0; i >= lo; i -= id.fi, j++){
                if(dist[i] > dist[curr] + j){
                    s.erase({dist[i], i});
                    dist[i] = dist[curr] + j;
                    s.insert({dist[i], i});
                }
                if(i != curr && vis[id.fi][i]) break;
            }
        }
    }
 
    cout << (dist[b[1]] == inf ? - 1 : dist[b[1]]) << endl;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:40:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < doge[i].size(); j++)
                        ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 3 ms 1016 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1148 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1020 KB Output is correct
5 Correct 3 ms 1016 KB Output is correct
6 Correct 3 ms 1016 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1144 KB Output is correct
10 Correct 3 ms 1528 KB Output is correct
11 Correct 4 ms 1656 KB Output is correct
12 Correct 3 ms 1144 KB Output is correct
13 Correct 3 ms 1144 KB Output is correct
14 Correct 4 ms 1528 KB Output is correct
15 Correct 4 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1016 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1144 KB Output is correct
10 Correct 4 ms 1528 KB Output is correct
11 Correct 4 ms 1528 KB Output is correct
12 Correct 3 ms 1272 KB Output is correct
13 Correct 3 ms 1144 KB Output is correct
14 Correct 4 ms 1484 KB Output is correct
15 Correct 4 ms 1400 KB Output is correct
16 Correct 4 ms 1912 KB Output is correct
17 Correct 6 ms 2808 KB Output is correct
18 Correct 6 ms 4344 KB Output is correct
19 Correct 5 ms 3064 KB Output is correct
20 Correct 4 ms 1272 KB Output is correct
21 Correct 6 ms 4600 KB Output is correct
22 Correct 5 ms 3576 KB Output is correct
23 Correct 7 ms 4216 KB Output is correct
24 Correct 9 ms 6008 KB Output is correct
25 Correct 9 ms 5624 KB Output is correct
26 Correct 4 ms 1656 KB Output is correct
27 Correct 5 ms 2424 KB Output is correct
28 Correct 6 ms 2296 KB Output is correct
29 Correct 8 ms 1400 KB Output is correct
30 Correct 5 ms 1244 KB Output is correct
31 Correct 6 ms 1400 KB Output is correct
32 Correct 5 ms 1272 KB Output is correct
33 Correct 10 ms 1656 KB Output is correct
34 Correct 11 ms 1660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1148 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1020 KB Output is correct
5 Correct 3 ms 1120 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1016 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1144 KB Output is correct
10 Correct 4 ms 1500 KB Output is correct
11 Correct 4 ms 1656 KB Output is correct
12 Correct 3 ms 1272 KB Output is correct
13 Correct 4 ms 1144 KB Output is correct
14 Correct 4 ms 1400 KB Output is correct
15 Correct 4 ms 1400 KB Output is correct
16 Correct 4 ms 1912 KB Output is correct
17 Correct 6 ms 2808 KB Output is correct
18 Correct 6 ms 4344 KB Output is correct
19 Correct 5 ms 3064 KB Output is correct
20 Correct 4 ms 1272 KB Output is correct
21 Correct 6 ms 4600 KB Output is correct
22 Correct 5 ms 3576 KB Output is correct
23 Correct 6 ms 4216 KB Output is correct
24 Correct 9 ms 6008 KB Output is correct
25 Correct 9 ms 5624 KB Output is correct
26 Correct 4 ms 1656 KB Output is correct
27 Correct 4 ms 2424 KB Output is correct
28 Correct 5 ms 2296 KB Output is correct
29 Correct 7 ms 1400 KB Output is correct
30 Correct 4 ms 1272 KB Output is correct
31 Correct 5 ms 1272 KB Output is correct
32 Correct 5 ms 1300 KB Output is correct
33 Correct 10 ms 1656 KB Output is correct
34 Correct 10 ms 1528 KB Output is correct
35 Correct 34 ms 10616 KB Output is correct
36 Correct 13 ms 8312 KB Output is correct
37 Correct 25 ms 6264 KB Output is correct
38 Correct 41 ms 11172 KB Output is correct
39 Correct 42 ms 11000 KB Output is correct
40 Correct 42 ms 11128 KB Output is correct
41 Correct 41 ms 11128 KB Output is correct
42 Correct 9 ms 2040 KB Output is correct
43 Correct 10 ms 2808 KB Output is correct
44 Correct 10 ms 1784 KB Output is correct
45 Correct 36 ms 4472 KB Output is correct
46 Correct 37 ms 4472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1016 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1012 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1144 KB Output is correct
10 Correct 3 ms 1400 KB Output is correct
11 Correct 4 ms 1528 KB Output is correct
12 Correct 3 ms 1144 KB Output is correct
13 Correct 3 ms 1116 KB Output is correct
14 Correct 4 ms 1528 KB Output is correct
15 Correct 4 ms 1528 KB Output is correct
16 Correct 4 ms 1912 KB Output is correct
17 Correct 6 ms 2936 KB Output is correct
18 Correct 6 ms 4344 KB Output is correct
19 Correct 5 ms 3064 KB Output is correct
20 Correct 4 ms 1272 KB Output is correct
21 Correct 8 ms 4600 KB Output is correct
22 Correct 5 ms 3576 KB Output is correct
23 Correct 6 ms 4216 KB Output is correct
24 Correct 9 ms 6008 KB Output is correct
25 Correct 8 ms 5624 KB Output is correct
26 Correct 4 ms 1656 KB Output is correct
27 Correct 5 ms 2424 KB Output is correct
28 Correct 5 ms 2296 KB Output is correct
29 Correct 7 ms 1400 KB Output is correct
30 Correct 4 ms 1272 KB Output is correct
31 Correct 5 ms 1272 KB Output is correct
32 Correct 4 ms 1320 KB Output is correct
33 Correct 10 ms 1528 KB Output is correct
34 Correct 10 ms 1656 KB Output is correct
35 Correct 35 ms 10616 KB Output is correct
36 Correct 13 ms 8312 KB Output is correct
37 Correct 26 ms 6392 KB Output is correct
38 Correct 41 ms 11128 KB Output is correct
39 Correct 43 ms 11088 KB Output is correct
40 Correct 41 ms 11256 KB Output is correct
41 Correct 41 ms 11064 KB Output is correct
42 Correct 9 ms 2040 KB Output is correct
43 Correct 10 ms 2808 KB Output is correct
44 Correct 9 ms 1656 KB Output is correct
45 Correct 36 ms 4476 KB Output is correct
46 Correct 37 ms 4472 KB Output is correct
47 Correct 61 ms 12920 KB Output is correct
48 Correct 76 ms 59768 KB Output is correct
49 Correct 79 ms 63096 KB Output is correct
50 Correct 57 ms 49528 KB Output is correct
51 Correct 241 ms 79708 KB Output is correct
52 Correct 166 ms 79268 KB Output is correct
53 Correct 69 ms 24312 KB Output is correct
54 Correct 8 ms 2552 KB Output is correct
55 Correct 9 ms 2680 KB Output is correct
56 Correct 33 ms 4856 KB Output is correct
57 Correct 64 ms 3192 KB Output is correct
58 Correct 14 ms 2936 KB Output is correct
59 Correct 16 ms 3192 KB Output is correct
60 Correct 18 ms 4216 KB Output is correct
61 Correct 31 ms 16640 KB Output is correct
62 Correct 50 ms 15864 KB Output is correct
63 Correct 114 ms 7292 KB Output is correct
64 Correct 121 ms 6684 KB Output is correct
65 Correct 140 ms 6620 KB Output is correct
66 Correct 259 ms 6616 KB Output is correct
67 Correct 271 ms 6620 KB Output is correct