这两个拓扑排序我觉得是一样的啊
但是交上去第二个就是错的
这个DAG不能通过10边转移
所以第二个代码就想着直接删掉10边也不会有影响
初始时,只有tot[s]=1
void tuopu(int s)
{
queue<int>q; q.push( s ); tot[s] = 1;
for(int i=1;i<=id;i++)
for(int j=0;j<=10;j++)
++in[sam[i].zi[j]];
while( !q.empty() )
{
int u = q.front(); q.pop();
for(int i=0;i<=10;i++)
{
int v = sam[u].zi[i];
if( v==0 ) continue;
if( i!=10 )
{
tot[v] = ( tot[v]+tot[u] )%mod;
f[v] = ( f[v]+f[u]*10%mod+i*tot[u]%mod )%mod;
}
if( --in[v]==0 ) q.push( v );
}
}
}
void tuopu(int s)
{
queue<int>q; q.push( s ); tot[s] = 1;
for(int i=1;i<=id;i++)
for(int j=0;j<10;j++)
++in[sam[i].zi[j]];
while( !q.empty() )
{
int u = q.front(); q.pop();
for(int i=0;i<10;i++)
{
int v = sam[u].zi[i];
if( v==0 ) continue;
tot[v] = ( tot[v]+tot[u] )%mod;
f[v] = ( f[v]+f[u]*10%mod+i*tot[u]%mod )%mod;
if( --in[v]==0 ) q.push( v );
}
}
}