voidinit(){ fill(head, head + maxn, -1); c1 = 0; for (int i = 1; i <= n; ++i) in[i] = 0; }
int id[maxn]; booltopsort(){ queue<int> Q; for (int i = 1; i <= n; ++i) if (!in[i]) Q.push(i); int cnt = 0; while (!Q.empty()) { int u = Q.front(); Q.pop(); id[u] = ++cnt; for (int i = head[u]; ~i; i = e[i].next) { int v = e[i].to; if (--in[v] == 0) Q.push(v); } } return cnt == n; }
boolcheck(int x){ init(); for (int i = x + 1; i <= m; ++i) add_edge(E[i].fr, E[i].to); return topsort(); }
cin >> n >> m; for (int i = 1; i <= m; ++i) cin >> E[i].fr >> E[i].to >> E[i].w, E[i].id = i; sort(E + 1, E + m + 1); int l = 0, r = m, mid, ans; while (l <= r) { mid = l + r >> 1; if (check(mid)) ans = mid, r = mid - 1; else l = mid + 1; } init(); check(ans); vector<int> Ans; for (int i = 1; i <= ans; ++i) if (id[E[i].fr] > id[E[i].to]) Ans.push_back(E[i].id); cout << E[ans].w << " " << Ans.size() << "\n"; for (auto u : Ans) cout << u << " "; return0; }