Submission #1168523

#TimeUsernameProblemLanguageResultExecution timeMemory
1168523chikien2009Bitaro’s Party (JOI18_bitaro)C++20
14 / 100
2092 ms6472 KiB
#include <bits/stdc++.h>

using namespace std;

inline void setup()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int n, m, q, y, t, a, b, f[100000];
vector<int> g[100000];
bool banned[100000];

int main()
{
    setup();

    cin >> n >> m >> q;
    for (int i = 0; i < m; ++i)
    {
        cin >> a >> b;
        if (a < b)
        {
            swap(a, b);
        }
        g[a - 1].push_back(b - 1);
    }
    while (q--)
    {
        cin >> t >> y;
        fill_n(f, n, -1);
        fill_n(banned, n, 0);
        a = -1;
        t--;
        while (y--)
        {
            cin >> b;
            banned[b - 1] = true;
        }
        f[t] = 0;
        for (int i = t; i >= 0; --i)
        {
            if (f[i] != -1)
            {
                if (!banned[i])
                {
                    a = max(a, f[i]);
                }
                for (auto & j : g[i])
                {
                    f[j] = max(f[j], f[i] + 1);
                }
            }
        }
        cout << a << "\n";
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...