답안 #905755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
905755 2024-01-13T04:37:34 Z Sir_Ahmed_Imran Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 191260 KB
                              ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long 
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define MAXN 30001
int x[MAXN];
int y[MAXN];
int dist[MAXN];
set<int> b[MAXN];
map<int,int> a[MAXN];
void solve(){
    int n,m,o,p,q,r;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x[i]>>y[i];
        b[x[i]].insert(y[i]);
    }
    for(int i=0;i<n;i++){
        dist[i]=INT_MAX;
        for(int j:b[i]){
            for(int k=i%j;k<n;k+=j){
                if(i==k) continue;
                if(a[i][k]==0)
                    a[i][k]=abs(i-k)/j;
                a[i][k]=min(a[i][k],abs(i-k)/j);
            }
        }
    }
    dist[x[0]]=0;
    set<pii> s{{0,x[0]}};
    while(!s.empty()){
        p=(*s.begin()).ss;
        q=(*s.begin()).ff;
        s.erase(s.begin());
        if(p==x[1]){
            cout<<q;
            return;
        }
        if(q==dist[p]){
            for(pii i:a[p]){
                if(q+i.ss<dist[i.ff]){
                    dist[i.ff]=q+i.ss;
                    s.insert({q+i.ss,i.ff});
                }  
            }
        }
    }
    cout<<-1;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    solve();
    return 0;
}

Compilation message

skyscraper.cpp: In function 'void solve()':
skyscraper.cpp:18:13: warning: unused variable 'o' [-Wunused-variable]
   18 |     int n,m,o,p,q,r;
      |             ^
skyscraper.cpp:18:19: warning: unused variable 'r' [-Wunused-variable]
   18 |     int n,m,o,p,q,r;
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3160 KB Output is correct
2 Correct 2 ms 3164 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 1 ms 3160 KB Output is correct
5 Correct 2 ms 3160 KB Output is correct
6 Correct 2 ms 3160 KB Output is correct
7 Correct 2 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3164 KB Output is correct
2 Correct 2 ms 3160 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 2 ms 3160 KB Output is correct
5 Correct 1 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 2 ms 3160 KB Output is correct
8 Correct 2 ms 3164 KB Output is correct
9 Correct 2 ms 3164 KB Output is correct
10 Correct 2 ms 3164 KB Output is correct
11 Correct 3 ms 3420 KB Output is correct
12 Correct 2 ms 3204 KB Output is correct
13 Correct 3 ms 3676 KB Output is correct
14 Correct 2 ms 3416 KB Output is correct
15 Correct 2 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3160 KB Output is correct
2 Correct 2 ms 3160 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 1 ms 3164 KB Output is correct
5 Correct 1 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 2 ms 3164 KB Output is correct
8 Correct 1 ms 3136 KB Output is correct
9 Correct 2 ms 3160 KB Output is correct
10 Correct 2 ms 3164 KB Output is correct
11 Correct 3 ms 3420 KB Output is correct
12 Correct 2 ms 3160 KB Output is correct
13 Correct 2 ms 3676 KB Output is correct
14 Correct 3 ms 3416 KB Output is correct
15 Correct 2 ms 3416 KB Output is correct
16 Correct 2 ms 3416 KB Output is correct
17 Correct 5 ms 4184 KB Output is correct
18 Correct 2 ms 3416 KB Output is correct
19 Correct 3 ms 3416 KB Output is correct
20 Correct 742 ms 191132 KB Output is correct
21 Correct 2 ms 3160 KB Output is correct
22 Correct 3 ms 3420 KB Output is correct
23 Correct 2 ms 3672 KB Output is correct
24 Correct 5 ms 3812 KB Output is correct
25 Correct 3 ms 3676 KB Output is correct
26 Correct 4 ms 3676 KB Output is correct
27 Correct 3 ms 3416 KB Output is correct
28 Correct 6 ms 4348 KB Output is correct
29 Correct 16 ms 4956 KB Output is correct
30 Correct 6 ms 4188 KB Output is correct
31 Correct 9 ms 4700 KB Output is correct
32 Correct 7 ms 4444 KB Output is correct
33 Correct 26 ms 5928 KB Output is correct
34 Correct 27 ms 5912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3164 KB Output is correct
2 Correct 2 ms 3164 KB Output is correct
3 Correct 1 ms 3164 KB Output is correct
4 Correct 2 ms 3364 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3160 KB Output is correct
7 Correct 2 ms 3164 KB Output is correct
8 Correct 2 ms 3172 KB Output is correct
9 Correct 2 ms 3164 KB Output is correct
10 Correct 2 ms 3164 KB Output is correct
11 Correct 3 ms 3416 KB Output is correct
12 Correct 2 ms 3164 KB Output is correct
13 Correct 3 ms 3676 KB Output is correct
14 Correct 3 ms 3420 KB Output is correct
15 Correct 3 ms 3420 KB Output is correct
16 Correct 2 ms 3420 KB Output is correct
17 Correct 5 ms 4344 KB Output is correct
18 Correct 2 ms 3420 KB Output is correct
19 Correct 2 ms 3416 KB Output is correct
20 Correct 731 ms 191056 KB Output is correct
21 Correct 2 ms 3160 KB Output is correct
22 Correct 3 ms 3420 KB Output is correct
23 Correct 3 ms 3676 KB Output is correct
24 Correct 5 ms 3984 KB Output is correct
25 Correct 4 ms 3684 KB Output is correct
26 Correct 3 ms 3644 KB Output is correct
27 Correct 3 ms 3416 KB Output is correct
28 Correct 4 ms 4188 KB Output is correct
29 Correct 15 ms 4976 KB Output is correct
30 Correct 6 ms 4184 KB Output is correct
31 Correct 10 ms 4696 KB Output is correct
32 Correct 6 ms 4440 KB Output is correct
33 Correct 30 ms 5980 KB Output is correct
34 Correct 28 ms 6228 KB Output is correct
35 Correct 28 ms 10576 KB Output is correct
36 Correct 5 ms 4188 KB Output is correct
37 Correct 61 ms 16880 KB Output is correct
38 Correct 47 ms 14724 KB Output is correct
39 Correct 60 ms 15372 KB Output is correct
40 Correct 57 ms 14824 KB Output is correct
41 Correct 60 ms 14376 KB Output is correct
42 Correct 6 ms 3932 KB Output is correct
43 Correct 8 ms 3672 KB Output is correct
44 Correct 772 ms 191260 KB Output is correct
45 Correct 124 ms 15172 KB Output is correct
46 Correct 131 ms 15168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3160 KB Output is correct
2 Correct 2 ms 3164 KB Output is correct
3 Correct 2 ms 3416 KB Output is correct
4 Correct 2 ms 3164 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 1 ms 3164 KB Output is correct
7 Correct 2 ms 3160 KB Output is correct
8 Correct 1 ms 3164 KB Output is correct
9 Correct 1 ms 3164 KB Output is correct
10 Correct 2 ms 3164 KB Output is correct
11 Correct 3 ms 3420 KB Output is correct
12 Correct 2 ms 3320 KB Output is correct
13 Correct 3 ms 3676 KB Output is correct
14 Correct 3 ms 3416 KB Output is correct
15 Correct 2 ms 3420 KB Output is correct
16 Correct 2 ms 3416 KB Output is correct
17 Correct 5 ms 4188 KB Output is correct
18 Correct 3 ms 3420 KB Output is correct
19 Correct 2 ms 3420 KB Output is correct
20 Correct 691 ms 191244 KB Output is correct
21 Correct 2 ms 3160 KB Output is correct
22 Correct 2 ms 3420 KB Output is correct
23 Correct 4 ms 3420 KB Output is correct
24 Correct 4 ms 3932 KB Output is correct
25 Correct 4 ms 3672 KB Output is correct
26 Correct 5 ms 3928 KB Output is correct
27 Correct 4 ms 3416 KB Output is correct
28 Correct 6 ms 4188 KB Output is correct
29 Correct 18 ms 4952 KB Output is correct
30 Correct 6 ms 4188 KB Output is correct
31 Correct 11 ms 4708 KB Output is correct
32 Correct 7 ms 4444 KB Output is correct
33 Correct 33 ms 5956 KB Output is correct
34 Correct 30 ms 5980 KB Output is correct
35 Correct 34 ms 10576 KB Output is correct
36 Correct 7 ms 4188 KB Output is correct
37 Correct 60 ms 16724 KB Output is correct
38 Correct 52 ms 14788 KB Output is correct
39 Correct 58 ms 15364 KB Output is correct
40 Correct 51 ms 14676 KB Output is correct
41 Correct 44 ms 14416 KB Output is correct
42 Correct 6 ms 3932 KB Output is correct
43 Correct 5 ms 3676 KB Output is correct
44 Correct 745 ms 191256 KB Output is correct
45 Correct 117 ms 14928 KB Output is correct
46 Correct 120 ms 14976 KB Output is correct
47 Correct 210 ms 53056 KB Output is correct
48 Correct 39 ms 14516 KB Output is correct
49 Correct 23 ms 10332 KB Output is correct
50 Correct 26 ms 10076 KB Output is correct
51 Correct 115 ms 23956 KB Output is correct
52 Correct 138 ms 27220 KB Output is correct
53 Correct 32 ms 9820 KB Output is correct
54 Correct 13 ms 5464 KB Output is correct
55 Correct 31 ms 8016 KB Output is correct
56 Execution timed out 1050 ms 182692 KB Time limit exceeded
57 Halted 0 ms 0 KB -