Submission #917106

# Submission time Handle Problem Language Result Execution time Memory
917106 2024-01-27T08:09:50 Z coding_snorlax Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 26492 KB
#include<bits/stdc++.h>
using namespace std;
set<pair<int,int>> s;
vector<int> List[30005];
int vis[30005]={0};
int Move[30005];
int N,M;
int answer = 50000;
void add(){
    auto now = *(s.begin());
    vis[now.second]=1;
    s.erase(s.begin());
    for(int i:List[now.second]){
        if(i==1) answer = min(answer,now.first);
        // doge M
        for(int j=now.second;j<=N;j+=Move[i]){
            if(!vis[j]) s.insert(make_pair(now.first+(j-now.second)/Move[i],j));
        }
        for(int j=now.second;j>=0;j-=Move[i]){
            if(!vis[j]) s.insert(make_pair(now.first+(now.second-j)/Move[i],j));
        }
    }
}
int main(){
    cin>>N>>M;
    int Bos;
    for(int i=0;i<M;i++){
        int tmp1,tmp2;
        cin>>tmp1>>tmp2;
        List[tmp1].push_back(i);
        Move[i]=tmp2;
        if(i==0) Bos = tmp1;
    }
    s.insert(make_pair(0,Bos));
    while((int)s.size()) add();
    if(answer!=50000) cout << answer;
    else cout << -1;

}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:34:29: warning: 'Bos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |     s.insert(make_pair(0,Bos));
      |                             ^
# 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 1116 KB Output is correct
7 Correct 1 ms 1116 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 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 1148 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Correct 2 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 2 ms 1116 KB Output is correct
15 Correct 2 ms 1116 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 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 1112 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 3 ms 1112 KB Output is correct
12 Correct 2 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 2 ms 1116 KB Output is correct
15 Correct 3 ms 1116 KB Output is correct
16 Correct 2 ms 1116 KB Output is correct
17 Correct 4 ms 1592 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1112 KB Output is correct
20 Correct 84 ms 1116 KB Output is correct
21 Correct 1 ms 1112 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 2 ms 1116 KB Output is correct
24 Correct 3 ms 1368 KB Output is correct
25 Correct 2 ms 1372 KB Output is correct
26 Correct 7 ms 1116 KB Output is correct
27 Correct 11 ms 1116 KB Output is correct
28 Correct 2 ms 1116 KB Output is correct
29 Correct 20 ms 4120 KB Output is correct
30 Correct 4 ms 1628 KB Output is correct
31 Correct 6 ms 1884 KB Output is correct
32 Correct 3 ms 1372 KB Output is correct
33 Correct 85 ms 7608 KB Output is correct
34 Correct 95 ms 7908 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 1 ms 1148 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1372 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 1144 KB Output is correct
11 Correct 2 ms 1160 KB Output is correct
12 Correct 2 ms 1116 KB Output is correct
13 Correct 2 ms 1116 KB Output is correct
14 Correct 2 ms 1156 KB Output is correct
15 Correct 2 ms 1112 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 4 ms 1372 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1372 KB Output is correct
20 Correct 84 ms 1328 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 2 ms 1116 KB Output is correct
24 Correct 3 ms 1372 KB Output is correct
25 Correct 2 ms 1372 KB Output is correct
26 Correct 7 ms 1116 KB Output is correct
27 Correct 10 ms 1244 KB Output is correct
28 Correct 3 ms 1116 KB Output is correct
29 Correct 20 ms 3932 KB Output is correct
30 Correct 4 ms 1628 KB Output is correct
31 Correct 6 ms 1884 KB Output is correct
32 Correct 4 ms 1372 KB Output is correct
33 Correct 85 ms 7504 KB Output is correct
34 Correct 84 ms 7640 KB Output is correct
35 Correct 43 ms 3932 KB Output is correct
36 Correct 5 ms 1368 KB Output is correct
37 Correct 73 ms 6140 KB Output is correct
38 Correct 63 ms 5320 KB Output is correct
39 Correct 72 ms 5456 KB Output is correct
40 Correct 69 ms 5460 KB Output is correct
41 Correct 60 ms 4872 KB Output is correct
42 Correct 92 ms 1624 KB Output is correct
43 Correct 170 ms 1628 KB Output is correct
44 Correct 117 ms 1740 KB Output is correct
45 Correct 276 ms 8784 KB Output is correct
46 Correct 283 ms 8912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1112 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 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 2 ms 1116 KB Output is correct
12 Correct 2 ms 1196 KB Output is correct
13 Correct 2 ms 1116 KB Output is correct
14 Correct 2 ms 1200 KB Output is correct
15 Correct 2 ms 1368 KB Output is correct
16 Correct 1 ms 1112 KB Output is correct
17 Correct 5 ms 1636 KB Output is correct
18 Correct 1 ms 1112 KB Output is correct
19 Correct 1 ms 1112 KB Output is correct
20 Correct 84 ms 1328 KB Output is correct
21 Correct 1 ms 1112 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 3 ms 1116 KB Output is correct
24 Correct 3 ms 1372 KB Output is correct
25 Correct 2 ms 1372 KB Output is correct
26 Correct 7 ms 1116 KB Output is correct
27 Correct 10 ms 1116 KB Output is correct
28 Correct 2 ms 1112 KB Output is correct
29 Correct 19 ms 4044 KB Output is correct
30 Correct 4 ms 1628 KB Output is correct
31 Correct 6 ms 1884 KB Output is correct
32 Correct 4 ms 1372 KB Output is correct
33 Correct 88 ms 7648 KB Output is correct
34 Correct 82 ms 7504 KB Output is correct
35 Correct 43 ms 3928 KB Output is correct
36 Correct 5 ms 1368 KB Output is correct
37 Correct 73 ms 6228 KB Output is correct
38 Correct 68 ms 5200 KB Output is correct
39 Correct 68 ms 5456 KB Output is correct
40 Correct 69 ms 5576 KB Output is correct
41 Correct 60 ms 4944 KB Output is correct
42 Correct 97 ms 1624 KB Output is correct
43 Correct 158 ms 1624 KB Output is correct
44 Correct 109 ms 1628 KB Output is correct
45 Correct 287 ms 8796 KB Output is correct
46 Correct 279 ms 8920 KB Output is correct
47 Correct 320 ms 26492 KB Output is correct
48 Correct 10 ms 1884 KB Output is correct
49 Correct 10 ms 1884 KB Output is correct
50 Correct 7 ms 1628 KB Output is correct
51 Correct 87 ms 10804 KB Output is correct
52 Correct 89 ms 11604 KB Output is correct
53 Correct 22 ms 4444 KB Output is correct
54 Correct 3 ms 1884 KB Output is correct
55 Correct 3 ms 1880 KB Output is correct
56 Execution timed out 1069 ms 4016 KB Time limit exceeded
57 Halted 0 ms 0 KB -