#include #include #include using namespace std; struct SS{ int from, to; bool isA; }; SS s[100010]; int best[1010]; int N, Z; char apa[10]; bool fc(SS a, SS b){ if(a.from < b.from) return true; if(a.from > b.from) return false; return false; } int main(){ int jcase; scanf("%d", &jcase); for(int icase=0; icase 0){ if(best[i] < best[i-1]) best[i] = best[i-1]; } for(int j=0; j best[s[j].to]) best[s[j].to] = best[i] + ctA; if(best[i] + ctB > best[s[j].to]) best[s[j].to] = best[i] + ctB; } //printf("best %d = %d\n", i, best[i]); } if(best[Z] < best[Z-1]) best[Z] = best[Z-1]; //printf("%d\n", best[Z]); int tgt = 1; for(int i=0; i<=Z; i++){ while(best[i] >= tgt){ printf("%d ", i+1); tgt++; } } for(int i=tgt; i<=N; i++){ printf("-1 "); } printf("\n"); } return 0; }