# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
453660 | Jokubas | Fire drill (LMIO18_sauga) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
/*void setIO(string s)
{
freopen((s + ".in").c_str(), "r", stdin);
}*/
int main()
{
//ios_base::sync_with_stdio(0); cin.tie(nullptr);
setIO("input");
int T, N, S;
cin>>T>>N>>S;
int kiek[N+1] = {0};
vector<int> listas[N+1];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> eil;
for(int i = 1; i<=N; i++)
{
int M;
cin>>M;
int a;
//int b = 0;
for(int j = 0; j<M; j++)
{
cin>>a;
kiek[i]++;
listas[a].pb(i);
}
}
for(int i = 1; i<=N; i++)
{
eil.push(make_pair(kiek[i], i));
}
/*0 4 1
2 2 3
0
1 4
1 1*/
map<int, bool> istrinti;
while(!eil.empty())
{
int a = eil.top().second;
eil.pop();
if(!istrinti.count(a))
{
for(auto c : listas[a])
{
kiek[c]--;
if(!istrinti.count(c))
{
eil.push(make_pair(kiek[c], c));
}
}
istrinti[a] = 1;
cout<<a<<"\n";
}
}
return 0;
}