Submission #992446

#TimeUsernameProblemLanguageResultExecution timeMemory
992446n3rm1nBitaro’s Party (JOI18_bitaro)C++17
0 / 100
2 ms6488 KiB
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
const int MAXN = 2e5 + 10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int n, m, q;
vector < int > g[MAXN];
int dp[MAXN];
int tt, yy;
int marked[MAXN];
void read()
{
    cin >> n >> m >> q;
    int from, to;
    for (int i = 1; i <= m; ++ i)
    {
        cin >> from >> to;
        g[from].push_back(to);
    }
    dp[1] = 0;
    for (int i = 1; i <= n; ++ i)
    {
        for (int j = 0; j < g[i].size(); ++ j)
            dp[i] = max(dp[i], dp[g[i][j]]);
    }
    while(q --)
    {
        cin >> tt >> yy;
        int x;
        memset(marked, 0, sizeof(marked));
        for (int i = 1; i <= yy; ++ i)
        {
            cin >> x;
            marked[x] = 1;
        }
        int maxx = 0;
        for (int i = tt; i >= 1; -- i)
        {
            if(i == tt)continue;
            for (int j = 0; j < g[i].size(); ++ j)
            {
                int nb = g[i][j];
                dp[i] = max(dp[i], dp[nb] + 1);
            }
            if(!marked[i])maxx = max(maxx, dp[i]);
        }
        cout << maxx << endl;
    }
}
int main()
{
    speed();

    read();
    return 0;
}
/***
5 6 1
1 2
2 4
3 4
1 3
3 5
4 5
5 2 2 3
/*/

Compilation message (stderr)

bitaro.cpp: In function 'void read()':
bitaro.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int j = 0; j < g[i].size(); ++ j)
      |                         ~~^~~~~~~~~~~~~
bitaro.cpp:46:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             for (int j = 0; j < g[i].size(); ++ j)
      |                             ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...