Submission #523019

# Submission time Handle Problem Language Result Execution time Memory
523019 2022-02-06T18:53:03 Z Deepesson Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 66172 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::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==2e7)break;
        if(__.first<0||__.first>=N)continue;
        if(!visitou.insert(*((bits*)&__)).second)continue;
        ++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:30: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   37 |         if(!visitou.insert(*((bits*)&__)).second)continue;
      |                             ~^~~~~~~~~~~
# 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 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 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 1 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 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 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
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 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 348 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 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 2 ms 588 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 4 ms 1356 KB Output is correct
29 Correct 17 ms 3228 KB Output is correct
30 Correct 4 ms 1100 KB Output is correct
31 Correct 9 ms 1864 KB Output is correct
32 Correct 6 ms 1420 KB Output is correct
33 Correct 38 ms 5904 KB Output is correct
34 Correct 18 ms 3360 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 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 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 0 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 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 588 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 1356 KB Output is correct
29 Correct 16 ms 3128 KB Output is correct
30 Correct 5 ms 1100 KB Output is correct
31 Correct 9 ms 1884 KB Output is correct
32 Correct 6 ms 1372 KB Output is correct
33 Correct 42 ms 5972 KB Output is correct
34 Correct 18 ms 3348 KB Output is correct
35 Correct 13 ms 2664 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 7 ms 1484 KB Output is correct
38 Correct 8 ms 1484 KB Output is correct
39 Correct 5 ms 716 KB Output is correct
40 Correct 6 ms 948 KB Output is correct
41 Correct 7 ms 1076 KB Output is correct
42 Correct 4 ms 844 KB Output is correct
43 Correct 5 ms 1136 KB Output is correct
44 Correct 5 ms 1104 KB Output is correct
45 Correct 206 ms 23264 KB Output is correct
46 Correct 94 ms 12424 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 204 KB Output is correct
7 Correct 1 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 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 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 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 588 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 4 ms 1356 KB Output is correct
29 Correct 16 ms 3148 KB Output is correct
30 Correct 4 ms 1100 KB Output is correct
31 Correct 9 ms 1868 KB Output is correct
32 Correct 6 ms 1356 KB Output is correct
33 Correct 38 ms 5908 KB Output is correct
34 Correct 19 ms 3352 KB Output is correct
35 Correct 14 ms 2636 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 7 ms 1580 KB Output is correct
38 Correct 8 ms 1612 KB Output is correct
39 Correct 6 ms 808 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 5 ms 1100 KB Output is correct
44 Correct 5 ms 1100 KB Output is correct
45 Correct 218 ms 23304 KB Output is correct
46 Correct 98 ms 12536 KB Output is correct
47 Correct 10 ms 1612 KB Output is correct
48 Correct 5 ms 1484 KB Output is correct
49 Correct 7 ms 1504 KB Output is correct
50 Correct 4 ms 1356 KB Output is correct
51 Correct 22 ms 4220 KB Output is correct
52 Correct 25 ms 4668 KB Output is correct
53 Correct 8 ms 2124 KB Output is correct
54 Correct 4 ms 1740 KB Output is correct
55 Correct 7 ms 2256 KB Output is correct
56 Correct 17 ms 3532 KB Output is correct
57 Correct 1 ms 1100 KB Output is correct
58 Correct 22 ms 4548 KB Output is correct
59 Correct 18 ms 4044 KB Output is correct
60 Correct 18 ms 4044 KB Output is correct
61 Correct 18 ms 4044 KB Output is correct
62 Correct 104 ms 23232 KB Output is correct
63 Execution timed out 1097 ms 66172 KB Time limit exceeded
64 Halted 0 ms 0 KB -