Submission #453094

#TimeUsernameProblemLanguageResultExecution timeMemory
453094jurgisFire drill (LMIO18_sauga)C++14
46.36 / 100
263 ms3792 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; int n, t, s; int laipsniai[1001]; vector<int> adj[1001]; vector<int> result; int isnaudotapak = 0; const int inf = 1e8; void toposort(){ for(int i = 0; i < n; i++){ int v , laip = inf; for(int j = 1; j <= n; j++){ if(laipsniai[j] < laip){ laip = laipsniai[j]; v = j; } } result.push_back(v); laipsniai[v] = inf; for(auto u : adj[v]){ laipsniai[u]--; } } } int main() { cin>>t>>n>>s; for(int i=0; i<n; i++){ int num; cin>>num; laipsniai[i+1] = num; for(int a=0; a<num; a++){ int u; cin>>u; adj[u].push_back(i+1); } } toposort(); for(auto i: result){ cout<<i<<"\n"; } } /* test case 0 4 1 2 2 3 0 1 4 1 1*/
#Verdict Execution timeMemoryGrader output
Fetching results...