Submission #45215

# Submission time Handle Problem Language Result Execution time Memory
45215 2018-04-11T21:34:46 Z ckodser Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 262144 KB
#include<bits/stdc++.h>

#define ll	int 
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=3e4+10;
const ll mod=1e9+7;
const ll inf=1e9+500;
const ll rad=110;
const ll maxm=maxn*(rad)*3+50;

ll b[maxn];
ll p[maxn];
vector<ll> vec[maxn];

ll cn;
vector<pair<ll,bool> > ger[maxm];
bitset<maxm> h;


int main(){

	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		cin>>b[i]>>p[i];
		vec[b[i]].pb(i);
	}
	for(ll i=0;i<n;i++){
		for(auto v:vec[i]){
			ger[i+m].pb(mp(v,0));
		}
	}	


	for(ll j=1;j<rad;j++){
		for(ll i=0;i<n;i++){
			ger[m+j*n+i].pb(mp(i+m,0));
			if(i>=j){
				ger[m+j*n+i].pb(mp(m+j*n+i-j,1));
			}
		}
	}
	for(ll j=1;j<rad;j++){
		for(ll i=0;i<n;i++){
			ll v=m+rad*n+(j-1)*n+i;
			ger[v].pb(mp(i+m,0));
			if(i+j<n){
				ger[v].pb(mp(v+j,1));
			}
		}
	}
	for(ll i=0;i<m;i++){
		if(p[i]<rad){
			ll v=b[i];
			ger[i].pb(mp(m+n*p[i]+v,0));
			ger[i].pb(mp(m+rad*n+(p[i]-1)*n+v,0));
		}
	}

	cn=m+n*2*rad+1;

	for(ll i=0;i<m;i++){
		if(p[i]>=rad){
			ll mo=cn;
			ger[i].pb(mp(cn,0));
			ger[cn].pb(mp(b[i]+m,0));
			cn++;
			for(ll j=b[i]+p[i];j<n;j+=p[i]){
				ger[cn].pb(mp(j+m,0));
				ger[cn-1].pb(mp(cn,1));
				cn++;
			}
			for(ll j=b[i]-p[i];j>=0;j-=p[i]){
				ger[cn].pb(mp(j+m,0));
				ger[mo].pb(mp(cn,1));
				mo=cn;
				cn++;
			}	
		}		
	}




	deque<pii>dk;
	dk.pb(mp(0,1));
	while(dk.size()){
		ll v=dk.front().F;
		ll w=dk.front().S;
		dk.pop_front();
		if(!h[v]){
			if(v==1){
				cout<<w-1;
				return 0;
			}
			h[v]=1;
			for(auto e:ger[v]){
				if(e.S){
					dk.push_back(mp(e.F,w+1));
				}else{
					dk.push_front(mp(e.F,w));
				}
			}
		}
	}
	cout<<-1;
}
# Verdict Execution time Memory Grader output
1 Correct 208 ms 233720 KB Output is correct
2 Correct 200 ms 233728 KB Output is correct
3 Correct 220 ms 233744 KB Output is correct
4 Correct 208 ms 233824 KB Output is correct
5 Correct 204 ms 233824 KB Output is correct
6 Correct 206 ms 233860 KB Output is correct
7 Correct 204 ms 233860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 233860 KB Output is correct
2 Correct 200 ms 233860 KB Output is correct
3 Correct 223 ms 233860 KB Output is correct
4 Correct 194 ms 234016 KB Output is correct
5 Correct 209 ms 234052 KB Output is correct
6 Correct 207 ms 234052 KB Output is correct
7 Correct 209 ms 234052 KB Output is correct
8 Correct 203 ms 234156 KB Output is correct
9 Correct 198 ms 234284 KB Output is correct
10 Correct 215 ms 234580 KB Output is correct
11 Correct 227 ms 234696 KB Output is correct
12 Correct 208 ms 234696 KB Output is correct
13 Correct 202 ms 234696 KB Output is correct
14 Correct 219 ms 234696 KB Output is correct
15 Correct 205 ms 234696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 217 ms 234696 KB Output is correct
2 Correct 207 ms 234696 KB Output is correct
3 Correct 180 ms 234696 KB Output is correct
4 Correct 196 ms 234696 KB Output is correct
5 Correct 192 ms 234696 KB Output is correct
6 Correct 207 ms 234696 KB Output is correct
7 Correct 182 ms 234696 KB Output is correct
8 Correct 182 ms 234696 KB Output is correct
9 Correct 181 ms 234696 KB Output is correct
10 Correct 184 ms 234748 KB Output is correct
11 Correct 182 ms 234748 KB Output is correct
12 Correct 190 ms 234748 KB Output is correct
13 Correct 186 ms 234748 KB Output is correct
14 Correct 184 ms 234748 KB Output is correct
15 Correct 182 ms 234748 KB Output is correct
16 Correct 194 ms 235260 KB Output is correct
17 Correct 205 ms 239356 KB Output is correct
18 Correct 225 ms 246128 KB Output is correct
19 Correct 241 ms 247692 KB Output is correct
20 Correct 232 ms 247732 KB Output is correct
21 Correct 188 ms 247732 KB Output is correct
22 Correct 227 ms 247732 KB Output is correct
23 Correct 227 ms 247732 KB Output is correct
24 Correct 233 ms 247732 KB Output is correct
25 Correct 262 ms 248020 KB Output is correct
26 Correct 275 ms 248020 KB Output is correct
27 Correct 302 ms 248024 KB Output is correct
28 Correct 258 ms 248264 KB Output is correct
29 Correct 324 ms 248264 KB Output is correct
30 Correct 259 ms 248264 KB Output is correct
31 Correct 245 ms 248264 KB Output is correct
32 Correct 314 ms 248264 KB Output is correct
33 Correct 294 ms 248264 KB Output is correct
34 Correct 244 ms 248264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 184 ms 248264 KB Output is correct
2 Correct 183 ms 248264 KB Output is correct
3 Correct 183 ms 248264 KB Output is correct
4 Correct 195 ms 248264 KB Output is correct
5 Correct 185 ms 248264 KB Output is correct
6 Correct 180 ms 248264 KB Output is correct
7 Correct 186 ms 248264 KB Output is correct
8 Correct 182 ms 248264 KB Output is correct
9 Correct 186 ms 248264 KB Output is correct
10 Correct 187 ms 248264 KB Output is correct
11 Correct 191 ms 248264 KB Output is correct
12 Correct 187 ms 248264 KB Output is correct
13 Correct 191 ms 248264 KB Output is correct
14 Correct 182 ms 248264 KB Output is correct
15 Correct 189 ms 248264 KB Output is correct
16 Correct 221 ms 248264 KB Output is correct
17 Correct 204 ms 248264 KB Output is correct
18 Correct 225 ms 248264 KB Output is correct
19 Correct 230 ms 248264 KB Output is correct
20 Correct 239 ms 248264 KB Output is correct
21 Correct 192 ms 248264 KB Output is correct
22 Correct 233 ms 248264 KB Output is correct
23 Correct 233 ms 248264 KB Output is correct
24 Correct 242 ms 248264 KB Output is correct
25 Correct 250 ms 248264 KB Output is correct
26 Correct 259 ms 248308 KB Output is correct
27 Correct 239 ms 248308 KB Output is correct
28 Correct 254 ms 248372 KB Output is correct
29 Correct 250 ms 248372 KB Output is correct
30 Correct 240 ms 248372 KB Output is correct
31 Correct 244 ms 248372 KB Output is correct
32 Correct 231 ms 248372 KB Output is correct
33 Correct 244 ms 248372 KB Output is correct
34 Correct 238 ms 248372 KB Output is correct
35 Correct 254 ms 248372 KB Output is correct
36 Correct 230 ms 248372 KB Output is correct
37 Correct 262 ms 252252 KB Output is correct
38 Correct 279 ms 253608 KB Output is correct
39 Correct 278 ms 253788 KB Output is correct
40 Correct 271 ms 253936 KB Output is correct
41 Correct 298 ms 254424 KB Output is correct
42 Correct 262 ms 254424 KB Output is correct
43 Correct 254 ms 254424 KB Output is correct
44 Correct 261 ms 254424 KB Output is correct
45 Correct 357 ms 261048 KB Output is correct
46 Correct 337 ms 261260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 185 ms 261260 KB Output is correct
2 Correct 183 ms 261260 KB Output is correct
3 Correct 195 ms 261260 KB Output is correct
4 Correct 185 ms 261260 KB Output is correct
5 Correct 192 ms 261260 KB Output is correct
6 Correct 182 ms 261260 KB Output is correct
7 Correct 183 ms 261260 KB Output is correct
8 Correct 190 ms 261260 KB Output is correct
9 Correct 185 ms 261260 KB Output is correct
10 Correct 202 ms 261260 KB Output is correct
11 Correct 199 ms 261260 KB Output is correct
12 Correct 202 ms 261260 KB Output is correct
13 Correct 186 ms 261260 KB Output is correct
14 Correct 197 ms 261260 KB Output is correct
15 Correct 186 ms 261260 KB Output is correct
16 Correct 189 ms 261260 KB Output is correct
17 Correct 207 ms 261260 KB Output is correct
18 Correct 243 ms 261260 KB Output is correct
19 Correct 242 ms 261260 KB Output is correct
20 Correct 241 ms 261260 KB Output is correct
21 Correct 199 ms 261260 KB Output is correct
22 Correct 228 ms 261260 KB Output is correct
23 Correct 231 ms 261260 KB Output is correct
24 Correct 237 ms 261260 KB Output is correct
25 Correct 237 ms 261260 KB Output is correct
26 Correct 238 ms 261260 KB Output is correct
27 Correct 234 ms 261260 KB Output is correct
28 Correct 238 ms 261260 KB Output is correct
29 Correct 234 ms 261260 KB Output is correct
30 Correct 230 ms 261260 KB Output is correct
31 Correct 270 ms 261260 KB Output is correct
32 Correct 242 ms 261260 KB Output is correct
33 Correct 262 ms 261260 KB Output is correct
34 Correct 238 ms 261260 KB Output is correct
35 Correct 253 ms 261260 KB Output is correct
36 Correct 223 ms 261260 KB Output is correct
37 Correct 268 ms 261260 KB Output is correct
38 Correct 283 ms 261260 KB Output is correct
39 Correct 277 ms 261260 KB Output is correct
40 Correct 276 ms 261260 KB Output is correct
41 Correct 281 ms 261260 KB Output is correct
42 Correct 262 ms 261260 KB Output is correct
43 Correct 260 ms 261260 KB Output is correct
44 Correct 263 ms 261260 KB Output is correct
45 Correct 349 ms 262144 KB Output is correct
46 Correct 324 ms 262144 KB Output is correct
47 Execution timed out 1079 ms 262144 KB Time limit exceeded
48 Halted 0 ms 0 KB -