Submission #523014

# Submission time Handle Problem Language Result Execution time Memory
523014 2022-02-06T18:49:00 Z Deepesson Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 95752 KB
#include <bits/stdc++.h>
#define MAX 31000
typedef std::pair<short,short> pii; ///Skyscraper .first, level .second
std::map<pii,std::vector<pii>> con;
typedef std::pair<pii,int> ppi;
typedef int bits;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    std::unordered_set<bits> visitou;
    int N,M;
    std::cin>>N>>M;
    bool cachorro[N]={};
    std::vector<int> poder[N];
    int ha[M],hb[M];
    for(int i=0;i!=M;++i){
        int a,b;
        std::cin>>a>>b;
        cachorro[a]=true;
        poder[a].push_back(b);
        ha[i]=a;
        hb[i]=b;
    }
    pii origem = {ha[0],hb[0]};
    pii fim = {ha[1],hb[1]};
    std::deque<ppi> deque;
    deque.push_back({origem,0});
    int count=0;
    while(deque.size()){
        auto ___ = deque.front();
        auto __ = ___.first;
        deque.pop_front();
        if(count==7e6)break;
        if(__.first<0||__.first>=N)continue;
        if(visitou.find(*((bits*)&__))!=visitou.end())continue;
        visitou.insert(*((bits*)&__));
        ++count;
        if(__==fim){
            std::cout<<___.second<<"\n";
            return 0;
        }
        deque.push_back({{__.first+__.second,__.second},___.second+1});
        deque.push_back({{__.first-__.second,__.second},___.second+1});
        if(cachorro[__.first]){
            cachorro[__.first]=false;
            for(auto&x:poder[__.first])
            deque.push_front({{__.first,x},___.second});
        }
    }
    std::cout<<"-1\n";
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:37:27: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   37 |         if(visitou.find(*((bits*)&__))!=visitou.end())continue;
      |                          ~^~~~~~~~~~~
skyscraper.cpp:38:26: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   38 |         visitou.insert(*((bits*)&__));
      |                         ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 588 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 360 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 2 ms 588 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 3 ms 1228 KB Output is correct
29 Correct 8 ms 2944 KB Output is correct
30 Correct 2 ms 972 KB Output is correct
31 Correct 4 ms 1704 KB Output is correct
32 Correct 4 ms 1484 KB Output is correct
33 Correct 16 ms 5440 KB Output is correct
34 Correct 10 ms 3036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 220 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 3 ms 588 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 2 ms 588 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 3 ms 1228 KB Output is correct
29 Correct 8 ms 2908 KB Output is correct
30 Correct 3 ms 972 KB Output is correct
31 Correct 5 ms 1704 KB Output is correct
32 Correct 3 ms 1484 KB Output is correct
33 Correct 18 ms 5440 KB Output is correct
34 Correct 14 ms 3036 KB Output is correct
35 Correct 10 ms 2440 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
37 Correct 6 ms 1484 KB Output is correct
38 Correct 7 ms 1484 KB Output is correct
39 Correct 6 ms 716 KB Output is correct
40 Correct 6 ms 972 KB Output is correct
41 Correct 6 ms 1100 KB Output is correct
42 Correct 4 ms 844 KB Output is correct
43 Correct 4 ms 1100 KB Output is correct
44 Correct 4 ms 972 KB Output is correct
45 Correct 186 ms 21460 KB Output is correct
46 Correct 53 ms 11508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 588 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 2 ms 588 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 4 ms 1100 KB Output is correct
29 Correct 9 ms 2908 KB Output is correct
30 Correct 2 ms 972 KB Output is correct
31 Correct 5 ms 1704 KB Output is correct
32 Correct 4 ms 1484 KB Output is correct
33 Correct 26 ms 5524 KB Output is correct
34 Correct 13 ms 3048 KB Output is correct
35 Correct 10 ms 2472 KB Output is correct
36 Correct 2 ms 460 KB Output is correct
37 Correct 6 ms 1524 KB Output is correct
38 Correct 7 ms 1484 KB Output is correct
39 Correct 5 ms 772 KB Output is correct
40 Correct 5 ms 972 KB Output is correct
41 Correct 6 ms 1100 KB Output is correct
42 Correct 4 ms 844 KB Output is correct
43 Correct 4 ms 1100 KB Output is correct
44 Correct 5 ms 972 KB Output is correct
45 Correct 160 ms 21388 KB Output is correct
46 Correct 67 ms 11500 KB Output is correct
47 Correct 6 ms 1504 KB Output is correct
48 Correct 5 ms 1488 KB Output is correct
49 Correct 5 ms 1484 KB Output is correct
50 Correct 4 ms 1432 KB Output is correct
51 Correct 17 ms 4268 KB Output is correct
52 Correct 17 ms 4444 KB Output is correct
53 Correct 10 ms 2124 KB Output is correct
54 Correct 2 ms 1612 KB Output is correct
55 Correct 3 ms 2124 KB Output is correct
56 Correct 9 ms 3496 KB Output is correct
57 Correct 1 ms 1112 KB Output is correct
58 Correct 11 ms 4188 KB Output is correct
59 Correct 10 ms 3884 KB Output is correct
60 Correct 10 ms 3804 KB Output is correct
61 Correct 10 ms 3932 KB Output is correct
62 Correct 186 ms 21788 KB Output is correct
63 Execution timed out 1016 ms 95752 KB Time limit exceeded
64 Halted 0 ms 0 KB -