Submission #915134

# Submission time Handle Problem Language Result Execution time Memory
915134 2024-01-23T11:49:56 Z Abito Viruses (BOI20_viruses) C++14
0 / 100
700 ms 604 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
//#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
#define y1 YONE
#define free freeee
#define lcm llcm
/*
⠄⠄⠄⠄⢠⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿⣿⣿⣿⣿⣯⢻⣿⣿⣿⣿⣆⠄⠄⠄
⠄⠄⣼⢀⣿⣿⣿⣿⣏⡏⠄⠹⣿⣿⣿⣿⣿⣿⣿⣿⣧⢻⣿⣿⣿⣿⡆⠄⠄
⠄⠄⡟⣼⣿⣿⣿⣿⣿⠄⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⣿⣇⢻⣿⣿⣿⣿⠄⠄
⠄⢰⠃⣿⣿⠿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠙⠿⣿⣿⣿⣿⣿⠄⢿⣿⣿⣿⡄⠄
⠄⢸⢠⣿⣿⣧⡙⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠈⠛⢿⣿⣿⡇⠸⣿⡿⣸⡇⠄
⠄⠈⡆⣿⣿⣿⣿⣦⡙⠳⠄⠄⠄⠄⠄⠄⢀⣠⣤⣀⣈⠙⠃⠄⠿⢇⣿⡇⠄
⠄⠄⡇⢿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⣠⣶⣿⣿⣿⣿⣿⣿⣷⣆⡀⣼⣿⡇⠄
⠄⠄⢹⡘⣿⣿⣿⢿⣷⡀⠄⢀⣴⣾⣟⠉⠉⠉⠉⣽⣿⣿⣿⣿⠇⢹⣿⠃⠄
⠄⠄⠄⢷⡘⢿⣿⣎⢻⣷⠰⣿⣿⣿⣿⣦⣀⣀⣴⣿⣿⣿⠟⢫⡾⢸⡟⠄.
⠄⠄⠄⠄⠻⣦⡙⠿⣧⠙⢷⠙⠻⠿⢿⡿⠿⠿⠛⠋⠉⠄⠂⠘⠁⠞⠄⠄⠄
⠄⠄⠄⠄⠄⠈⠙⠑⣠⣤⣴⡖⠄⠿⣋⣉⣉⡁⠄⢾⣦⠄⠄⠄⠄⠄⠄⠄⠄
*/
typedef unsigned long long ull;
using namespace std;
const int N=1e3+5;
int g,n,m,dp[N];
vector<int> adj[N];
vector<vector<int>> mut[N];
bool comp[N][N],vis[N];
void dfs(int x){
    vis[x]=true;
    for (auto u:adj[x]){
        if (vis[u]) continue;
        dfs(u);
    }return;
}
int rec(int x){
    vis[x]=true;
    dp[x]=INT_MAX;
    for (auto u:mut[x]){
        bool ok=true;
        for (auto v:u){
            if (comp[v][x]){
                ok=false;break;
            }
        }if (!ok) continue;
        int z=0;
        for (auto v:u){
            if (v<2) z++;
            else z+=rec(v);
        }dp[x]=min(dp[x],z);
    }return dp[x];
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>g>>n>>m;
    for (int i=1;i<=n;i++){
        int x,k;cin>>x>>k;
        vector<int> v(k);
        for (int j=0;j<k;j++){
            cin>>v[j];
            if (v[j]>1) adj[x].pb(v[j]);
        }
        mut[x].pb(v);
    }
    for (int i=2;i<g;i++){
        for (int j=2;j<g;j++){
            dfs(i);
            bool x=vis[j];
            memset(vis,0,sizeof(vis));
            if (!x) continue;
            dfs(j);
            bool y=vis[i];
            memset(vis,0,sizeof(vis));
            if (!y) continue;
            comp[i][j]=true;
            //cout<<i<<' '<<j<<endl;
        }
    }
    for (int i=2;i<g;i++){
        int x=rec(i);
        if (x==INT_MAX) cout<<"YES"<<endl;
        else cout<<"NO "<<x<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Execution timed out 1085 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Execution timed out 1065 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Execution timed out 1085 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Execution timed out 1085 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -