Submission #523009

# Submission time Handle Problem Language Result Execution time Memory
523009 2022-02-06T18:44:48 Z Deepesson Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 92324 KB
#include <bits/stdc++.h>
#define MAX 31000
typedef std::pair<int,int> pii; ///Skyscraper .first, level .second
std::map<pii,std::vector<pii>> con;
typedef std::pair<pii,int> ppi;
typedef std::bitset<sizeof(pii)*8> 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==5e6)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 0 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 1 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 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 216 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 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 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 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 1 ms 204 KB Output is correct
10 Correct 0 ms 204 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 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 2 ms 588 KB Output is correct
28 Correct 5 ms 1228 KB Output is correct
29 Correct 14 ms 2908 KB Output is correct
30 Correct 4 ms 972 KB Output is correct
31 Correct 7 ms 1704 KB Output is correct
32 Correct 6 ms 1484 KB Output is correct
33 Correct 28 ms 5368 KB Output is correct
34 Correct 15 ms 3036 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 0 ms 204 KB Output is correct
4 Correct 1 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 1 ms 204 KB Output is correct
8 Correct 1 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 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 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 0 ms 332 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 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 2 ms 588 KB Output is correct
28 Correct 5 ms 1228 KB Output is correct
29 Correct 14 ms 2908 KB Output is correct
30 Correct 5 ms 972 KB Output is correct
31 Correct 8 ms 1704 KB Output is correct
32 Correct 6 ms 1436 KB Output is correct
33 Correct 29 ms 5388 KB Output is correct
34 Correct 15 ms 2992 KB Output is correct
35 Correct 12 ms 2600 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 7 ms 1612 KB Output is correct
38 Correct 8 ms 1612 KB Output is correct
39 Correct 5 ms 716 KB Output is correct
40 Correct 6 ms 992 KB Output is correct
41 Correct 7 ms 1192 KB Output is correct
42 Correct 8 ms 840 KB Output is correct
43 Correct 5 ms 1228 KB Output is correct
44 Correct 5 ms 1100 KB Output is correct
45 Correct 223 ms 21528 KB Output is correct
46 Correct 84 ms 11672 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 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 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 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 2 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 0 ms 332 KB Output is correct
17 Correct 2 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 2 ms 460 KB Output is correct
24 Correct 3 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 588 KB Output is correct
28 Correct 5 ms 1228 KB Output is correct
29 Correct 16 ms 2908 KB Output is correct
30 Correct 4 ms 972 KB Output is correct
31 Correct 7 ms 1704 KB Output is correct
32 Correct 6 ms 1484 KB Output is correct
33 Correct 29 ms 5436 KB Output is correct
34 Correct 15 ms 3036 KB Output is correct
35 Correct 12 ms 2660 KB Output is correct
36 Correct 2 ms 460 KB Output is correct
37 Correct 7 ms 1624 KB Output is correct
38 Correct 8 ms 1612 KB Output is correct
39 Correct 6 ms 716 KB Output is correct
40 Correct 6 ms 972 KB Output is correct
41 Correct 8 ms 1100 KB Output is correct
42 Correct 4 ms 844 KB Output is correct
43 Correct 5 ms 1264 KB Output is correct
44 Correct 5 ms 1100 KB Output is correct
45 Correct 217 ms 21356 KB Output is correct
46 Correct 83 ms 11852 KB Output is correct
47 Correct 6 ms 1484 KB Output is correct
48 Correct 5 ms 1484 KB Output is correct
49 Correct 5 ms 1484 KB Output is correct
50 Correct 4 ms 1356 KB Output is correct
51 Correct 20 ms 4364 KB Output is correct
52 Correct 24 ms 4544 KB Output is correct
53 Correct 9 ms 2124 KB Output is correct
54 Correct 4 ms 1612 KB Output is correct
55 Correct 6 ms 2124 KB Output is correct
56 Correct 14 ms 3472 KB Output is correct
57 Correct 2 ms 1100 KB Output is correct
58 Correct 19 ms 4096 KB Output is correct
59 Correct 20 ms 3792 KB Output is correct
60 Correct 19 ms 3800 KB Output is correct
61 Correct 19 ms 4324 KB Output is correct
62 Correct 196 ms 22064 KB Output is correct
63 Execution timed out 1096 ms 92324 KB Time limit exceeded
64 Halted 0 ms 0 KB -