답안 #103874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
103874 2019-04-03T04:20:42 Z tduong0806 Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 51060 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
#define read2(a,b) read(a),read(b)
#define read3(a,b,c) read(a),read(b),read(c)
const int N=30100;
int n,m,a[N],v[N];
vector<int> ke[N];
unordered_map<int,int> f[N];
queue<pii> q;
void Push(int i,int p,int c)
{
    if(i-p>=0&&!f[i-p][p]) f[i-p][p]=c+1,q.push({i-p,p});
    if(i+p<=n&&!f[i+p][p]) f[i+p][p]=c+1,q.push({i+p,p});
}
void BFS()
{
    int s=v[1];
    forv(u,ke[s]) if(!f[s][u]) f[s][u]=1,q.push({s,u});
    while(!q.empty())
    {
        pii u=q.front();q.pop();
        int c=f[u.fi][u.se];
        if(u.fi==v[2]) {cout<<c-1;exit(0);}
        Push(u.fi,u.se,c);
        forv(v,ke[u.fi]) Push(u.fi,v,c);
    }
    cout<<-1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("JAKARTA.inp","r",stdin);
    cin>>n>>m;
    forinc(i,1,m)
    {
        int p;
        cin>>v[i]>>p;
        ke[v[i]].pb(p);
    }
    BFS();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 4 ms 2688 KB Output is correct
5 Correct 5 ms 2688 KB Output is correct
6 Correct 5 ms 2688 KB Output is correct
7 Correct 5 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 4 ms 2688 KB Output is correct
5 Correct 5 ms 2688 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 5 ms 2688 KB Output is correct
8 Correct 5 ms 2688 KB Output is correct
9 Correct 5 ms 2688 KB Output is correct
10 Correct 5 ms 2688 KB Output is correct
11 Correct 7 ms 2816 KB Output is correct
12 Correct 5 ms 2688 KB Output is correct
13 Correct 4 ms 2688 KB Output is correct
14 Correct 7 ms 2944 KB Output is correct
15 Correct 5 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2688 KB Output is correct
2 Correct 4 ms 2736 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 5 ms 2688 KB Output is correct
5 Correct 4 ms 2688 KB Output is correct
6 Correct 4 ms 2588 KB Output is correct
7 Correct 5 ms 2688 KB Output is correct
8 Correct 5 ms 2688 KB Output is correct
9 Correct 5 ms 2688 KB Output is correct
10 Correct 5 ms 2688 KB Output is correct
11 Correct 7 ms 2816 KB Output is correct
12 Correct 5 ms 2688 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 8 ms 2944 KB Output is correct
15 Correct 6 ms 2816 KB Output is correct
16 Correct 5 ms 2688 KB Output is correct
17 Correct 9 ms 2944 KB Output is correct
18 Correct 7 ms 2688 KB Output is correct
19 Correct 5 ms 2688 KB Output is correct
20 Correct 6 ms 2944 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 5 ms 2688 KB Output is correct
23 Correct 7 ms 2944 KB Output is correct
24 Correct 9 ms 3072 KB Output is correct
25 Correct 5 ms 2816 KB Output is correct
26 Correct 6 ms 2944 KB Output is correct
27 Correct 7 ms 2944 KB Output is correct
28 Correct 12 ms 3584 KB Output is correct
29 Correct 26 ms 5220 KB Output is correct
30 Correct 10 ms 3584 KB Output is correct
31 Correct 17 ms 4224 KB Output is correct
32 Correct 11 ms 3712 KB Output is correct
33 Correct 52 ms 7772 KB Output is correct
34 Correct 30 ms 5632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 4 ms 2688 KB Output is correct
5 Correct 4 ms 2688 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 5 ms 2660 KB Output is correct
8 Correct 4 ms 2688 KB Output is correct
9 Correct 5 ms 2816 KB Output is correct
10 Correct 5 ms 2816 KB Output is correct
11 Correct 6 ms 2816 KB Output is correct
12 Correct 7 ms 2688 KB Output is correct
13 Correct 5 ms 2816 KB Output is correct
14 Correct 11 ms 2944 KB Output is correct
15 Correct 5 ms 2816 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 5 ms 2944 KB Output is correct
18 Correct 6 ms 2724 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 7 ms 2944 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 4 ms 2688 KB Output is correct
23 Correct 6 ms 2944 KB Output is correct
24 Correct 8 ms 3072 KB Output is correct
25 Correct 5 ms 2816 KB Output is correct
26 Correct 5 ms 2944 KB Output is correct
27 Correct 6 ms 2944 KB Output is correct
28 Correct 17 ms 3704 KB Output is correct
29 Correct 24 ms 5248 KB Output is correct
30 Correct 12 ms 3584 KB Output is correct
31 Correct 16 ms 4224 KB Output is correct
32 Correct 12 ms 3712 KB Output is correct
33 Correct 52 ms 7800 KB Output is correct
34 Correct 39 ms 5624 KB Output is correct
35 Correct 29 ms 4344 KB Output is correct
36 Correct 6 ms 2816 KB Output is correct
37 Correct 16 ms 3968 KB Output is correct
38 Correct 23 ms 4480 KB Output is correct
39 Correct 15 ms 3072 KB Output is correct
40 Correct 11 ms 3072 KB Output is correct
41 Correct 12 ms 3300 KB Output is correct
42 Correct 12 ms 3072 KB Output is correct
43 Correct 9 ms 3200 KB Output is correct
44 Correct 10 ms 3200 KB Output is correct
45 Correct 576 ms 23640 KB Output is correct
46 Correct 416 ms 15052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 5 ms 2688 KB Output is correct
5 Correct 4 ms 2688 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 5 ms 2688 KB Output is correct
9 Correct 4 ms 2688 KB Output is correct
10 Correct 4 ms 2688 KB Output is correct
11 Correct 4 ms 2688 KB Output is correct
12 Correct 6 ms 2688 KB Output is correct
13 Correct 5 ms 2688 KB Output is correct
14 Correct 9 ms 2944 KB Output is correct
15 Correct 6 ms 2816 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 6 ms 2944 KB Output is correct
18 Correct 4 ms 2688 KB Output is correct
19 Correct 4 ms 2736 KB Output is correct
20 Correct 5 ms 2816 KB Output is correct
21 Correct 4 ms 2736 KB Output is correct
22 Correct 4 ms 2688 KB Output is correct
23 Correct 6 ms 2944 KB Output is correct
24 Correct 6 ms 2988 KB Output is correct
25 Correct 7 ms 2816 KB Output is correct
26 Correct 7 ms 2944 KB Output is correct
27 Correct 6 ms 2944 KB Output is correct
28 Correct 14 ms 3712 KB Output is correct
29 Correct 26 ms 5248 KB Output is correct
30 Correct 10 ms 3456 KB Output is correct
31 Correct 19 ms 4420 KB Output is correct
32 Correct 15 ms 3804 KB Output is correct
33 Correct 40 ms 7804 KB Output is correct
34 Correct 28 ms 5624 KB Output is correct
35 Correct 26 ms 4352 KB Output is correct
36 Correct 5 ms 2816 KB Output is correct
37 Correct 15 ms 3968 KB Output is correct
38 Correct 26 ms 4480 KB Output is correct
39 Correct 14 ms 3072 KB Output is correct
40 Correct 11 ms 3148 KB Output is correct
41 Correct 13 ms 3328 KB Output is correct
42 Correct 11 ms 3152 KB Output is correct
43 Correct 11 ms 3200 KB Output is correct
44 Correct 16 ms 3200 KB Output is correct
45 Correct 703 ms 23612 KB Output is correct
46 Correct 437 ms 15096 KB Output is correct
47 Correct 27 ms 4096 KB Output is correct
48 Correct 17 ms 3200 KB Output is correct
49 Correct 18 ms 3200 KB Output is correct
50 Correct 11 ms 3072 KB Output is correct
51 Correct 47 ms 5752 KB Output is correct
52 Correct 64 ms 6404 KB Output is correct
53 Correct 18 ms 3712 KB Output is correct
54 Correct 9 ms 3684 KB Output is correct
55 Correct 11 ms 4124 KB Output is correct
56 Correct 31 ms 5632 KB Output is correct
57 Correct 5 ms 2816 KB Output is correct
58 Correct 50 ms 6264 KB Output is correct
59 Correct 32 ms 5880 KB Output is correct
60 Correct 37 ms 5880 KB Output is correct
61 Correct 36 ms 5616 KB Output is correct
62 Correct 584 ms 23012 KB Output is correct
63 Execution timed out 1070 ms 51060 KB Time limit exceeded
64 Halted 0 ms 0 KB -