답안 #453111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
453111 2021-08-04T08:04:38 Z jurgis Fire drill (LMIO18_sauga) C++14
10 / 100
1000 ms 262148 KB
#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(){
    priority_queue<pair<int, int> > q;
    for(int i = 1; i <= n; i++){
        q.push({-laipsniai[i], i});
    }
    while(!q.empty()){
        int v = q.top().second;
        int laip = -q.top().first;
        q.pop();
        if(laip != laipsniai[v]) continue;
        result.push_back(v);
        for(auto x : adj[v]){
            laipsniai[x]--;
            q.push({-laipsniai[x], x});
        }
    }
}
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*/
# 결과 실행 시간 메모리 Grader output
1 Correct 228 ms 7240 KB Output is correct
2 Execution timed out 1086 ms 98756 KB Time limit exceeded
3 Execution timed out 1086 ms 93900 KB Time limit exceeded
4 Execution timed out 1080 ms 146752 KB Time limit exceeded
5 Execution timed out 1094 ms 164452 KB Time limit exceeded
6 Execution timed out 1091 ms 156384 KB Time limit exceeded
7 Execution timed out 1084 ms 160156 KB Time limit exceeded
8 Runtime error 900 ms 262148 KB Execution killed with signal 9
9 Execution timed out 1084 ms 144576 KB Time limit exceeded
10 Execution timed out 1087 ms 48600 KB Time limit exceeded