Submission #623527

# Submission time Handle Problem Language Result Execution time Memory
623527 2022-08-05T18:59:02 Z inksamurai Jetpack (COCI16_jetpack) C++17
0 / 80
19 ms 10604 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3SgiE60 ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
// e

const int inf=100010;

signed main(){
_3SgiE60;
	const int h=10;
	int w;
	cin>>w;
	vec(vec(char)) a(h,vec(char)(w));
	rep(i,h){
		rep(j,w){
			cin>>a[i][j];
		}
	}
	auto ok=[&](int x,int y){
		return min(x,y)>=0 and x<h and y<w;
	};
	const int di[]={-1,1};
	const int dj[]={1,1};
	vec(vi) usd(h,vi(w,-1));
	auto reachable=[&](auto self,int x,int y)->bool{
		if(usd[x][y]!=-1) return usd[x][y];
		if(y==w-1) return usd[x][y]=true;
		int nx=x+di[0],ny=y+dj[0];
		bool pok=0;
		if(ok(nx,ny) and a[nx][ny]=='.'){
			pok=pok or self(self,nx,ny);
		}
		nx=x+di[1],ny=y+dj[1];
		nx=min(nx,h-1);
		if(ok(nx,ny) and a[nx][ny]=='.'){
			pok=pok or self(self,nx,ny);
		}
		return usd[x][y]=pok;
	};
	assert(reachable(reachable,h-1,0));
	// using T=pair<int,pii>;
	// vec(vec(T)) dp(h,vec(T)(w));
	// rep(i,h){
	// 	rep(j,w){
	// 		dp[i][j]={inf,{-1,-1}};
	// 	}
	// }
	// auto affine=[&](int sx,int sy,int val,int x,int y,int ad)->void{
	// 	val+=ad;
	// 	if(dp[sx][sy].fi>val){
	// 		dp[sx][sy].fi=val;
	// 		dp[sx][sy].se={x,y};
	// 	}
	// };
	// auto dfs=[&](auto self,int x,int y)->int{
	// 	assert(a[x][y]=='.');
	// 	if(dp[x][y].fi!=inf) return dp[x][y].fi;
	// 	if(y==w-1) return dp[x][y].fi=0;
	// 	dp[x][y].fi=inf-1;
	// 	int sx=x,sy=y;
	// 	rep(_,11){
	// 		x+=di[0],y+=dj[0];
	// 		if(ok(x,y) and a[x][y]=='.'){
	// 			int nval=self(self,x,y);
	// 			if(nval<=w){
	// 				affine(sx,sy,nval,x,y,1);
	// 			}
	// 		}else{
	// 			break;
	// 		}
	// 	}
	// 	x=sx,y=sy;
	// 	x+=di[1],y+=dj[1];
	// 	x=min(x,h-1);
	// 	if(ok(x,y) and a[x][y]=='.'){
	// 		int nval=self(self,x,y);
	// 		if(nval<=w){
	// 			affine(sx,sy,nval,x,y,0);
	// 		}
	// 	}
	// 	return dp[sx][sy].fi;
	// };
	// dfs(dfs,h-1,0);
	// int x=h-1,y=0;
	// assert(dp[x][y].fi<inf-1);
	// cout<<dp[x][y].fi<<"\n";
	// while(y<w-1){
	// 	// print(x,y);
	// 	int nx,ny;
	// 	nx=dp[x][y].se.fi,ny=dp[x][y].se.se;
	// 	if(nx==-1 and ny==-1) break;
	// 	if(nx<x){
	// 		cout<<y<<" "<<ny-y<<"\n";
	// 	}
	// 	x=nx,y=ny;
	// }
}

Compilation message

jetpack.cpp: In instantiation of 'main()::<lambda(auto:23, int, int)> [with auto:23 = main()::<lambda(auto:23, int, int)>]':
jetpack.cpp:54:2:   required from here
jetpack.cpp:41:30: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   41 |   if(y==w-1) return usd[x][y]=true;
jetpack.cpp:52:19: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   52 |   return usd[x][y]=pok;
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
2 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
3 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
4 Incorrect 1 ms 340 KB Unexpected end of file - int32 expected
5 Incorrect 2 ms 980 KB Unexpected end of file - int32 expected
6 Runtime error 2 ms 1236 KB Execution killed with signal 6
7 Runtime error 5 ms 2644 KB Execution killed with signal 6
8 Runtime error 10 ms 5400 KB Execution killed with signal 6
9 Runtime error 18 ms 7856 KB Execution killed with signal 6
10 Runtime error 19 ms 10604 KB Execution killed with signal 6