Submission #1097635

# Submission time Handle Problem Language Result Execution time Memory
1097635 2024-10-07T17:35:49 Z Noname_1900 Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
207 ms 225616 KB
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 30000;
vector<int> chienSurTour[NMAX];
int puissanceChien[NMAX];
bool trouveTour[NMAX];
struct T {
    int tour = 0, puissance = 0;
    T(int a, int b)
    {
        tour = a;
        puissance = b;
    }
};
bool dejaVu[NMAX][NMAX];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int nbTours, nbChiens;
    cin >> nbTours >> nbChiens;
    int pos0;
    for(int i = 0; i < nbChiens; i++)
    {
        int deb, p;
        cin >> deb >> p;
        puissanceChien[i] = p;
        if(i == 0)
        {
            pos0 = deb;
        }
        chienSurTour[deb].push_back(i);
    }
    vector<T> caseMaint;
    vector<T> proCase;
    proCase.push_back(T(pos0, 0));
    int distance = -1;
    while(proCase.size())
    {
        distance++;
        caseMaint = proCase;
        proCase.clear();
        for(auto cas : caseMaint)
        {
            
            if(cas.tour >= nbTours) continue;
            if(cas.tour < 0)    continue;
            if(dejaVu[cas.tour][cas.puissance]) continue;
            dejaVu[cas.tour][cas.puissance] = true;
            proCase.push_back(T(cas.tour - cas.puissance, cas.puissance));
            proCase.push_back(T(cas.tour + cas.puissance, cas.puissance));
            if(!trouveTour[cas.tour])
            {
                trouveTour[cas.tour] = true;
                for(int c : chienSurTour[cas.tour])
                {
                    if(c == 1)  
                    {
                        cout << distance;
                        return 0;
                    }

                    proCase.push_back(T(cas.tour - puissanceChien[c], puissanceChien[c]));
                    proCase.push_back(T(cas.tour + puissanceChien[c], puissanceChien[c]));
                    
                }
            }
        }
    }
    cout << -1;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:11:14: warning: 'pos0' may be used uninitialized in this function [-Wmaybe-uninitialized]
   11 |         tour = a;
      |         ~~~~~^~~
skyscraper.cpp:22:9: note: 'pos0' was declared here
   22 |     int pos0;
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 1 ms 1112 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 1 ms 1628 KB Output is correct
15 Correct 1 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1368 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 1 ms 1628 KB Output is correct
15 Correct 1 ms 1628 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 3676 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 4 ms 9308 KB Output is correct
21 Correct 2 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 4 ms 7516 KB Output is correct
24 Correct 4 ms 9340 KB Output is correct
25 Correct 2 ms 2652 KB Output is correct
26 Correct 4 ms 8028 KB Output is correct
27 Correct 4 ms 8540 KB Output is correct
28 Correct 6 ms 9820 KB Output is correct
29 Correct 5 ms 9252 KB Output is correct
30 Correct 4 ms 9308 KB Output is correct
31 Correct 6 ms 9308 KB Output is correct
32 Correct 7 ms 9356 KB Output is correct
33 Correct 8 ms 9560 KB Output is correct
34 Correct 6 ms 9312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1112 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 0 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 2 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 2 ms 1628 KB Output is correct
14 Correct 1 ms 1624 KB Output is correct
15 Correct 1 ms 1628 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 3676 KB Output is correct
18 Correct 2 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 5 ms 9332 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 6 ms 7516 KB Output is correct
24 Correct 7 ms 9308 KB Output is correct
25 Correct 2 ms 2652 KB Output is correct
26 Correct 6 ms 8028 KB Output is correct
27 Correct 5 ms 8400 KB Output is correct
28 Correct 5 ms 9820 KB Output is correct
29 Correct 8 ms 9416 KB Output is correct
30 Correct 4 ms 9308 KB Output is correct
31 Correct 5 ms 9304 KB Output is correct
32 Correct 7 ms 9308 KB Output is correct
33 Correct 8 ms 9436 KB Output is correct
34 Correct 7 ms 9304 KB Output is correct
35 Correct 8 ms 8916 KB Output is correct
36 Correct 2 ms 2140 KB Output is correct
37 Correct 6 ms 6616 KB Output is correct
38 Correct 8 ms 9028 KB Output is correct
39 Correct 4 ms 1372 KB Output is correct
40 Correct 5 ms 1628 KB Output is correct
41 Correct 9 ms 2908 KB Output is correct
42 Correct 6 ms 8284 KB Output is correct
43 Correct 6 ms 8796 KB Output is correct
44 Correct 8 ms 10520 KB Output is correct
45 Correct 22 ms 11896 KB Output is correct
46 Correct 12 ms 11812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1112 KB Output is correct
6 Correct 1 ms 1112 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 1 ms 1628 KB Output is correct
15 Correct 1 ms 1628 KB Output is correct
16 Correct 1 ms 952 KB Output is correct
17 Correct 2 ms 3672 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 4 ms 9308 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 3 ms 7516 KB Output is correct
24 Correct 4 ms 9308 KB Output is correct
25 Correct 2 ms 2648 KB Output is correct
26 Correct 4 ms 8040 KB Output is correct
27 Correct 3 ms 8540 KB Output is correct
28 Correct 6 ms 9820 KB Output is correct
29 Correct 5 ms 9308 KB Output is correct
30 Correct 4 ms 9304 KB Output is correct
31 Correct 4 ms 9304 KB Output is correct
32 Correct 4 ms 9308 KB Output is correct
33 Correct 7 ms 9564 KB Output is correct
34 Correct 5 ms 9304 KB Output is correct
35 Correct 8 ms 8880 KB Output is correct
36 Correct 2 ms 2136 KB Output is correct
37 Correct 5 ms 6616 KB Output is correct
38 Correct 7 ms 9092 KB Output is correct
39 Correct 4 ms 1372 KB Output is correct
40 Correct 4 ms 1624 KB Output is correct
41 Correct 5 ms 3160 KB Output is correct
42 Correct 6 ms 8280 KB Output is correct
43 Correct 6 ms 8828 KB Output is correct
44 Correct 9 ms 10640 KB Output is correct
45 Correct 15 ms 12064 KB Output is correct
46 Correct 11 ms 11812 KB Output is correct
47 Correct 10 ms 14676 KB Output is correct
48 Correct 4 ms 1624 KB Output is correct
49 Correct 4 ms 1628 KB Output is correct
50 Correct 3 ms 1372 KB Output is correct
51 Correct 59 ms 126952 KB Output is correct
52 Correct 74 ms 156440 KB Output is correct
53 Correct 13 ms 21080 KB Output is correct
54 Correct 27 ms 62812 KB Output is correct
55 Correct 36 ms 82768 KB Output is correct
56 Correct 55 ms 123732 KB Output is correct
57 Correct 2 ms 2908 KB Output is correct
58 Correct 56 ms 124472 KB Output is correct
59 Correct 53 ms 114184 KB Output is correct
60 Correct 53 ms 114256 KB Output is correct
61 Correct 57 ms 110928 KB Output is correct
62 Correct 119 ms 225616 KB Output is correct
63 Correct 125 ms 141272 KB Output is correct
64 Correct 122 ms 135372 KB Output is correct
65 Correct 146 ms 133424 KB Output is correct
66 Correct 207 ms 132376 KB Output is correct
67 Correct 130 ms 128784 KB Output is correct