| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1081772 | KALARRY | Bitaro’s Party (JOI18_bitaro) | C++14 | 1808 ms | 219756 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//chockolateman
#include<bits/stdc++.h>
using namespace std;
int S = 150;
int N,M,Q,cur_dp[100005];
vector<pair<int,int>> dp[100005];
vector<int> adj_rev[100005];
bool visited[100005],prohibited[100005];
vector<pair<int,int>> temp;
bool did[100005];
void dfs(int v)
{
    if(visited[v])
        return;
    visited[v] = true;
    temp.push_back({-1,0});
    temp.push_back({0,v});
    for(auto u : adj_rev[v])
    {
        dfs(u);
        for(auto x : dp[u])
            if(x.first != -1)
                temp.push_back({x.first+1,x.second});
    }
    sort(temp.begin(),temp.end(),greater<pair<int,int>>());
    for(auto x : temp)
    {
        if(dp[v].size()==S)
            break;
        if(!did[x.second])
        {
            did[x.second] = true;
            dp[v].push_back(x);
        }
    }
    for(auto x : dp[v])
        did[x.second] = false;
    temp.clear();
    
}
void dfs2(int v)
{
    if(visited[v])
        return;
    visited[v] = true;
    if(!prohibited[v])
        cur_dp[v] = 0;
    for(auto u : adj_rev[v])
    {
        dfs2(u);
        if(cur_dp[u] != -1)
            cur_dp[v] = max(cur_dp[v],cur_dp[u] + 1);
    }
}
int main()
{
    scanf("%d%d%d",&N,&M,&Q);
    for(int a,b,i = 1 ; i <= M ; i++)
    {
        scanf("%d%d",&a,&b);
        adj_rev[b].push_back(a);
    }
    for(int i = 1 ; i <= N ; i++)
        dfs(i);
    for(int t,y,i = 1 ; i <= Q ; i++)
    {
        vector<int> busy;
        scanf("%d%d",&t,&y);
        for(int a,j = 1 ; j <= y ; j++)
        {
            scanf("%d",&a);
            busy.push_back(a);
            prohibited[a] = true;
        }
        if(busy.size() <= S)
        {
            int ans = -1;
            for(auto x : dp[t])
                if(!prohibited[x.second])
                    ans = max(ans,x.first);
            printf("%d\n",ans);
        }
        else
        {
            for(int j = 1 ; j <= N ; j++)
            {
                cur_dp[j] = -1;
                visited[j] = false;
            }
            dfs2(t);
            printf("%d\n",cur_dp[t]);
        }
        for(auto a : busy)
            prohibited[a] = false;
    }
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
