답안 #1097634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097634 2024-10-07T17:33:20 Z Noname_1900 Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 222640 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, chien = 0;
    T(int a, int b)
    {
        tour = a;
        chien = 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.chien]) continue;
            dejaVu[cas.tour][cas.chien] = true;
            proCase.push_back(T(cas.tour - puissanceChien[cas.chien], cas.chien));
            proCase.push_back(T(cas.tour + puissanceChien[cas.chien], cas.chien));
            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], c));
                    proCase.push_back(T(cas.tour + puissanceChien[c], 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;
      |         ^~~~
# 결과 실행 시간 메모리 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 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 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 0 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 1200 KB Output is correct
12 Correct 1 ms 1624 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 1 ms 1940 KB Output is correct
15 Correct 1 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 1 ms 996 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 0 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 1 ms 1116 KB Output is correct
11 Correct 1 ms 1112 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 1 ms 1884 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 4188 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 52 ms 13392 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 9564 KB Output is correct
25 Correct 2 ms 2648 KB Output is correct
26 Correct 3 ms 8028 KB Output is correct
27 Correct 4 ms 8280 KB Output is correct
28 Correct 6 ms 12388 KB Output is correct
29 Correct 8 ms 10584 KB Output is correct
30 Correct 4 ms 9372 KB Output is correct
31 Correct 5 ms 10332 KB Output is correct
32 Correct 4 ms 10076 KB Output is correct
33 Correct 8 ms 13228 KB Output is correct
34 Correct 7 ms 12636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 0 ms 964 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 1116 KB Output is correct
7 Correct 0 ms 1172 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 1908 KB Output is correct
14 Correct 1 ms 1884 KB Output is correct
15 Correct 1 ms 1688 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 4184 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 57 ms 13316 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1096 KB Output is correct
23 Correct 3 ms 7516 KB Output is correct
24 Correct 5 ms 9560 KB Output is correct
25 Correct 2 ms 2652 KB Output is correct
26 Correct 4 ms 8024 KB Output is correct
27 Correct 4 ms 8420 KB Output is correct
28 Correct 6 ms 12408 KB Output is correct
29 Correct 6 ms 10696 KB Output is correct
30 Correct 6 ms 9564 KB Output is correct
31 Correct 6 ms 10328 KB Output is correct
32 Correct 5 ms 9956 KB Output is correct
33 Correct 10 ms 13148 KB Output is correct
34 Correct 8 ms 12636 KB Output is correct
35 Correct 15 ms 26388 KB Output is correct
36 Correct 2 ms 2140 KB Output is correct
37 Correct 6 ms 8664 KB Output is correct
38 Correct 9 ms 14276 KB Output is correct
39 Correct 4 ms 1628 KB Output is correct
40 Correct 4 ms 2056 KB Output is correct
41 Correct 7 ms 3232 KB Output is correct
42 Correct 6 ms 8536 KB Output is correct
43 Correct 7 ms 9052 KB Output is correct
44 Correct 94 ms 61404 KB Output is correct
45 Correct 51 ms 62232 KB Output is correct
46 Correct 36 ms 60188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 932 KB Output is correct
4 Correct 0 ms 1116 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
8 Correct 0 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 2 ms 1884 KB Output is correct
14 Correct 1 ms 1884 KB Output is correct
15 Correct 1 ms 1628 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 3 ms 4188 KB Output is correct
18 Correct 1 ms 1176 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 56 ms 13364 KB Output is correct
21 Correct 1 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 9564 KB Output is correct
25 Correct 2 ms 2652 KB Output is correct
26 Correct 5 ms 8028 KB Output is correct
27 Correct 5 ms 8284 KB Output is correct
28 Correct 6 ms 12380 KB Output is correct
29 Correct 6 ms 10588 KB Output is correct
30 Correct 4 ms 9436 KB Output is correct
31 Correct 5 ms 10364 KB Output is correct
32 Correct 5 ms 10076 KB Output is correct
33 Correct 11 ms 13144 KB Output is correct
34 Correct 8 ms 12636 KB Output is correct
35 Correct 15 ms 26324 KB Output is correct
36 Correct 2 ms 2140 KB Output is correct
37 Correct 6 ms 8664 KB Output is correct
38 Correct 11 ms 14404 KB Output is correct
39 Correct 5 ms 1628 KB Output is correct
40 Correct 5 ms 2124 KB Output is correct
41 Correct 5 ms 3420 KB Output is correct
42 Correct 7 ms 8540 KB Output is correct
43 Correct 7 ms 9048 KB Output is correct
44 Correct 104 ms 61600 KB Output is correct
45 Correct 49 ms 62236 KB Output is correct
46 Correct 38 ms 60184 KB Output is correct
47 Correct 11 ms 16728 KB Output is correct
48 Correct 4 ms 1884 KB Output is correct
49 Correct 4 ms 1884 KB Output is correct
50 Correct 3 ms 1624 KB Output is correct
51 Correct 72 ms 132816 KB Output is correct
52 Correct 86 ms 164892 KB Output is correct
53 Correct 17 ms 25692 KB Output is correct
54 Correct 31 ms 62684 KB Output is correct
55 Correct 41 ms 82772 KB Output is correct
56 Execution timed out 1113 ms 222640 KB Time limit exceeded
57 Halted 0 ms 0 KB -