Pagini recente » Cod sursa (job #1383803) | Cod sursa (job #2920336) | Cod sursa (job #432401) | Cod sursa (job #483057) | Cod sursa (job #2568359)
#include <bits/stdc++.h>
#define FILE_NAME "pioni"
#define fast ios_base :: sync_with_stdio(0); cin.tie(0);
#pragma GCC optimize("O3")
#define NMAX 20100
using namespace std;
ifstream f(FILE_NAME ".in");
ofstream g(FILE_NAME ".out");
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef pair<ld,ld> pct;
const ll inf = 1LL << 60;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
void add(ll &a , ll b)
{
a += b;
a %= mod;
}
void sub(ll &a, ll b)
{
a = (a - b + mod) % mod;
}
int t, n , m, x, y,win[NMAX], k, urm[NMAX];
vector <int> G[NMAX], ans;
bitset <NMAX> start, viz;
void DFS(int nod)
{
viz[nod] = 1;
for(auto it : G[nod])
{
if(!viz[it])
DFS(it);
if((win[it] ^ 1) == 1 )
urm[nod] = it;
win[nod] = win[nod] | (win[it] ^ 1);
}
}
int main()
{
f >> t >> n >> m;
for(int i = 1; i <= m; ++i)
{
f >> x >> y;
G[x].push_back(y);
start[y] = 1;
}
for(int i = 1; i <= n; ++i)
if(!start[i])
DFS(i);
while(t--)
{
f >> k;
int cat = 0;
for(int i = 1; i <= k; ++i)
{
f >> x;
if(win[x])
{
cat++;
ans.push_back(x);
}
}
if(cat == 0)
g << "Fumeanu\n";
else
{
g << "Nargy\n";
g << ans.size() << ' ';
for(auto it : ans)
g << it << ' ' << urm[it] << ' ';
g << '\n';
}
ans.clear();
}
f.close();
g.close();
return 0;
}