# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
735345 | 2023-05-04T03:12:44 Z | ReLice | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 243 ms | 262144 KB |
#include <bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define endl "\n" #define fr first #define sc second #define sz size() #define bc back() using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}*/ void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=1e9+7; const ll mod=1e9+7; const ll N=2e3+7; ll n,l,r,d[N]; vector <vector <pair<ll,ll>> > g(N); void dijkstra(ll val){ set <pair<ll,ll>> q; q.insert({0,val}); d[val]=0; while(!q.empty()){ ll x=q.begin()->sc; q.erase(q.begin()); for(auto i : g[x]){ ll len=i.sc,to=i.fr; if(d[to]>d[x]+len){ d[to]=d[x]+len; q.insert({d[to],to}); } } } } void solve(){ ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t; ll k; cin>>n>>m; vector <pair<ll,ll> > v; for(i=0;i<m;i++){ cin>>b>>t; if(i==0) k=b; if(i==1) t=b; c=0; for(j=b+t;j<n;j+=t){ c++; g[b].pb({j,c}); } c=0; for(j=b-t;j>=0;j-=t){ c++; g[b].pb({j,c}); } } for(i=0;i<n;i++) d[i]=inf; dijkstra(k); if(d[t]==inf) cout<<-1<<endl; else cout<<d[t]<<endl; } signed main(){ //start(); //fre(""); ll t=1; //cin>>t; while(t--) solve(); } /* 5 3 0 2 1 1 4 1 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Runtime error | 230 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Runtime error | 235 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Runtime error | 243 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 268 KB | Output is correct |
2 | Runtime error | 242 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Runtime error | 230 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |