Submission #674966

#TimeUsernameProblemLanguageResultExecution timeMemory
674966DenkataBitaro’s Party (JOI18_bitaro)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>#define endl '\n'using namespace std;vector <int> v[100006];int i,j,p,q,n,m,k,y,t;int Q;vector <pair <int,int>> best[100006];const int crit = 1;int used[100006];int dp[100006];int covered[100006];int dfs(int u){ if(covered[u]==Q+1) return dp[u]; covered[u]=Q+1; dp[u]=-1; if(used[u]!=Q+1)dp[u]=0; for(auto j:v[u]) { int val = dfs(j); if(val!=-1) dp[u]=max(dp[u],1+val); } return dp[u];}int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>m>>Q; for(i=1; i<=m; i++) { cin>>p>>q; v[q].push_back(p); } for(i=1; i<=n; i++) { for(auto j:v[i]) { best[i].push_back({-1,j}); for(auto k:best[j]) best[i].push_back({k.first-1,k.second}); } sort(best[i].begin(),best[i].end()); while(best[i].size()>crit) best[i].pop_back(); } while(Q--) { int party; cin>>party; cin>>y; for(i=1; i<=y; i++) { cin>>t; used[t]=Q+1; } bool fl=0; for(i=0; i<best[party].size(); i++) { if(used[best[party][i].second]!=Q+1) { cout<<abs(best[party][i].first)<<endl; fl=1; break; } } if(fl)continue; if(y<crit) { if(used[party]==Q+1) cout<<-1<<endl; else cout<<0<<endl; continue; } cout<<dfs(party)<<endl; } return 0;}

Compilation message (stderr)

bitaro.cpp:1:24: warning: extra tokens at end of #include directive
    1 | #include<bits/stdc++.h>#define endl '\n'using namespace std;vector <int> v[100006];int i,j,p,q,n,m,k,y,t;int Q;vector <pair <int,int>> best[100006];const int crit = 1;int used[100006];int dp[100006];int covered[100006];int dfs(int u){    if(covered[u]==Q+1)        return dp[u];    covered[u]=Q+1;    dp[u]=-1;    if(used[u]!=Q+1)dp[u]=0;    for(auto j:v[u])    {        int val = dfs(j);        if(val!=-1)            dp[u]=max(dp[u],1+val);    }    return dp[u];}int main(){    ios_base::sync_with_stdio(false);    cin.tie(NULL);    cout.tie(NULL);    cin>>n>>m>>Q;    for(i=1; i<=m; i++)    {        cin>>p>>q;        v[q].push_back(p);    }    for(i=1; i<=n; i++)    {        for(auto j:v[i])        {            best[i].push_back({-1,j});            for(auto k:best[j])                best[i].push_back({k.first-1,k.second});        }        sort(best[i].begin(),best[i].end());        while(best[i].size()>crit)            best[i].pop_back();    }    while(Q--)    {        int party;        cin>>party;        cin>>y;        for(i=1; i<=y; i++)        {            cin>>t;            used[t]=Q+1;        }        bool fl=0;        for(i=0; i<best[party].size(); i++)        {            if(used[best[party][i].second]!=Q+1)            {                cout<<abs(best[party][i].first)<<endl;                fl=1;                break;            }        }        if(fl)continue;        if(y<crit)        {            if(used[party]==Q+1)                cout<<-1<<endl;            else cout<<0<<endl;            continue;        }        cout<<dfs(party)<<endl;    }    return 0;}
      |                        ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status