import java.io.*; import java.util.*; class Main { static final long MOD=201712111; static final long I9=powerMod(9,MOD-2); static long[][][]dp2; static long powerMod(long x, long exponent) { long prod = 1; for (int i = 63; i >= 0; --i) { prod = (prod * prod) % MOD; if ((exponent & 1L << i) != 0) { prod = (prod * x) % MOD; } } return prod; } Main(int h,int w,int[][]b){ int[][]dp; dp=new int[h][w]; for(int i=0;i0)m=Math.min(m,dp[i-1][j-1]+c); dp[i][j]=m; } int indet=0; for(int[]r:b) for(int rr:r) if(rr==-1)indet++; long[][]dp2=new long[h][1<0&&dp[i-1][j-1]+c==dp[i][j]) alt[ps][1]=1<<(j-1); if(alt[ps][0]==0) alt[ps][0]=alt[ps][1]; if(alt[ps][1]==0) alt[ps][1]=alt[ps][0]; if(alt[ps][0]==alt[ps][1]) p|=alt[ps][0]; else ps++; } long total=0; int[]taplis=new int[1<