UVALive 4255 Guess
Question:
Give you a half matrix. If the position of (I, j) is '-', sum [I... j] <0 if it is '+', it means sum> 0 if it is '0'. sum = 0 indicates that the absolute value of the sequence element satisfying this matrix is less than 10.
Ideas:
It is easy to think that sum [I... j] To sum [j]-sum [I-1] That is to use prefix and to represent the matrix in the question can be converted to prefix and the size comparison between them that we can by prefix and point uses the relationship of size as the edge to obtain the prefix and topological order that satisfies the meaning of the question. Then, you only need to make the topological order larger than the smaller one to easily control the absolute value of the element.
Code:
#include
#include
#includeusing namespace std;#define N 15int T,n;int in[N],sum[N],vis[N],qu[N],maz[N][N];char str[N*N];void topo(){ int i,j,k,s,f; for(i=0,k=0,f=10;i<=n;k=0,f--) { for(j=0;j<=n;j++) { if(!vis[j]&&!in[j]) qu[k++]=j; } i+=k; for(j=0,s=k;j