# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
905862 | 2024-01-13T05:31:40 Z | Sir_Ahmed_Imran | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 34 ms | 16732 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 M 30001 #define N 2001 int x[M]; int e[N]; int vis[N][N]; vector<int> a[N]; vector<int> b[N]; void solve(){ int n,m,o,p,q,r; cin>>n>>m; for(int i=o=0;i<m;i++){ cin>>x[i]>>q; if(!vis[x[i]][q]) a[x[i]].append(q); vis[x[i]][q]=1; } set<int> c; unordered_set<int> v{x[0]},u; while(!v.empty()){ for(auto& i:v){ e[i]=1; if(i==x[1]){ cout<<o; return; } } for(auto& i:v){ for(auto& j:a[i]){ if(i>=j && !vis[i-j][j]){ if(e[i-j]){ c.insert(i-j); b[i-j].append(j); } else a[i-j].append(j); vis[i-j][j]=1; u.insert(i-j); } if(i+j<n && !vis[i+j][j]){ if(e[i+j]){ c.insert(i+j); b[i+j].append(j); } else a[i+j].append(j); vis[i+j][j]=1; u.insert(i+j); } if(i>=j && !a[i-j].empty() && !e[i-j]) u.insert(i-j); if(i+j<n && !a[i+j].empty() && !e[i+j]) u.insert(i+j); } e[i]=0; a[i].clear(); } o++; for(auto& i:c){ for(auto& j:b[i]) a[i].append(j); b[i].clear(); } swap(v,u); u.clear(); c.clear(); } cout<<-1; } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 600 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 1 ms | 860 KB | Output is correct |
11 | Correct | 1 ms | 860 KB | Output is correct |
12 | Correct | 1 ms | 856 KB | Output is correct |
13 | Correct | 1 ms | 856 KB | Output is correct |
14 | Correct | 1 ms | 856 KB | Output is correct |
15 | Correct | 1 ms | 860 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 604 KB | Output is correct |
9 | Correct | 1 ms | 600 KB | Output is correct |
10 | Correct | 1 ms | 860 KB | Output is correct |
11 | Correct | 1 ms | 860 KB | Output is correct |
12 | Correct | 1 ms | 860 KB | Output is correct |
13 | Correct | 1 ms | 860 KB | Output is correct |
14 | Correct | 2 ms | 856 KB | Output is correct |
15 | Correct | 1 ms | 856 KB | Output is correct |
16 | Correct | 2 ms | 1372 KB | Output is correct |
17 | Correct | 4 ms | 4184 KB | Output is correct |
18 | Correct | 3 ms | 3932 KB | Output is correct |
19 | Correct | 2 ms | 2652 KB | Output is correct |
20 | Correct | 7 ms | 8540 KB | Output is correct |
21 | Correct | 2 ms | 2908 KB | Output is correct |
22 | Correct | 2 ms | 3164 KB | Output is correct |
23 | Correct | 5 ms | 9052 KB | Output is correct |
24 | Correct | 8 ms | 12124 KB | Output is correct |
25 | Correct | 4 ms | 7516 KB | Output is correct |
26 | Correct | 4 ms | 7600 KB | Output is correct |
27 | Correct | 5 ms | 8284 KB | Output is correct |
28 | Correct | 8 ms | 10588 KB | Output is correct |
29 | Correct | 9 ms | 9052 KB | Output is correct |
30 | Correct | 9 ms | 8792 KB | Output is correct |
31 | Correct | 8 ms | 8796 KB | Output is correct |
32 | Correct | 7 ms | 9052 KB | Output is correct |
33 | Correct | 16 ms | 9308 KB | Output is correct |
34 | Correct | 10 ms | 9052 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 600 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 1 ms | 860 KB | Output is correct |
11 | Correct | 1 ms | 856 KB | Output is correct |
12 | Correct | 1 ms | 856 KB | Output is correct |
13 | Correct | 1 ms | 860 KB | Output is correct |
14 | Correct | 2 ms | 860 KB | Output is correct |
15 | Correct | 1 ms | 860 KB | Output is correct |
16 | Correct | 1 ms | 1624 KB | Output is correct |
17 | Correct | 4 ms | 4188 KB | Output is correct |
18 | Correct | 3 ms | 3932 KB | Output is correct |
19 | Correct | 2 ms | 2652 KB | Output is correct |
20 | Correct | 5 ms | 8536 KB | Output is correct |
21 | Correct | 2 ms | 2908 KB | Output is correct |
22 | Correct | 2 ms | 3164 KB | Output is correct |
23 | Correct | 6 ms | 9048 KB | Output is correct |
24 | Correct | 8 ms | 12120 KB | Output is correct |
25 | Correct | 6 ms | 7516 KB | Output is correct |
26 | Correct | 4 ms | 7516 KB | Output is correct |
27 | Correct | 5 ms | 8284 KB | Output is correct |
28 | Correct | 11 ms | 10588 KB | Output is correct |
29 | Correct | 14 ms | 9048 KB | Output is correct |
30 | Correct | 9 ms | 8792 KB | Output is correct |
31 | Correct | 8 ms | 8796 KB | Output is correct |
32 | Correct | 8 ms | 8896 KB | Output is correct |
33 | Correct | 19 ms | 9304 KB | Output is correct |
34 | Correct | 9 ms | 9052 KB | Output is correct |
35 | Correct | 12 ms | 12124 KB | Output is correct |
36 | Correct | 5 ms | 8284 KB | Output is correct |
37 | Correct | 16 ms | 14428 KB | Output is correct |
38 | Correct | 16 ms | 16476 KB | Output is correct |
39 | Correct | 21 ms | 16732 KB | Output is correct |
40 | Correct | 15 ms | 16476 KB | Output is correct |
41 | Correct | 15 ms | 16472 KB | Output is correct |
42 | Correct | 7 ms | 7512 KB | Output is correct |
43 | Correct | 8 ms | 8540 KB | Output is correct |
44 | Correct | 9 ms | 8740 KB | Output is correct |
45 | Correct | 34 ms | 11604 KB | Output is correct |
46 | Correct | 19 ms | 10844 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 604 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 1 ms | 860 KB | Output is correct |
11 | Correct | 2 ms | 856 KB | Output is correct |
12 | Correct | 1 ms | 856 KB | Output is correct |
13 | Correct | 1 ms | 856 KB | Output is correct |
14 | Correct | 1 ms | 860 KB | Output is correct |
15 | Correct | 1 ms | 860 KB | Output is correct |
16 | Correct | 1 ms | 1368 KB | Output is correct |
17 | Correct | 3 ms | 4188 KB | Output is correct |
18 | Correct | 2 ms | 3932 KB | Output is correct |
19 | Correct | 2 ms | 2652 KB | Output is correct |
20 | Correct | 5 ms | 8540 KB | Output is correct |
21 | Correct | 2 ms | 2908 KB | Output is correct |
22 | Correct | 3 ms | 3164 KB | Output is correct |
23 | Correct | 5 ms | 9052 KB | Output is correct |
24 | Correct | 7 ms | 12120 KB | Output is correct |
25 | Correct | 5 ms | 7512 KB | Output is correct |
26 | Correct | 4 ms | 7516 KB | Output is correct |
27 | Correct | 5 ms | 8284 KB | Output is correct |
28 | Correct | 9 ms | 10588 KB | Output is correct |
29 | Correct | 10 ms | 9076 KB | Output is correct |
30 | Correct | 6 ms | 8796 KB | Output is correct |
31 | Correct | 7 ms | 8796 KB | Output is correct |
32 | Correct | 7 ms | 9052 KB | Output is correct |
33 | Correct | 13 ms | 9320 KB | Output is correct |
34 | Correct | 10 ms | 9044 KB | Output is correct |
35 | Correct | 14 ms | 12124 KB | Output is correct |
36 | Correct | 6 ms | 8284 KB | Output is correct |
37 | Correct | 12 ms | 14424 KB | Output is correct |
38 | Correct | 19 ms | 16476 KB | Output is correct |
39 | Correct | 15 ms | 16476 KB | Output is correct |
40 | Correct | 17 ms | 16564 KB | Output is correct |
41 | Correct | 18 ms | 16472 KB | Output is correct |
42 | Correct | 8 ms | 7772 KB | Output is correct |
43 | Correct | 11 ms | 8536 KB | Output is correct |
44 | Correct | 7 ms | 8540 KB | Output is correct |
45 | Correct | 32 ms | 11612 KB | Output is correct |
46 | Correct | 19 ms | 10840 KB | Output is correct |
47 | Runtime error | 1 ms | 604 KB | Execution killed with signal 11 |
48 | Halted | 0 ms | 0 KB | - |