Submission #748167

# Submission time Handle Problem Language Result Execution time Memory
748167 2023-05-25T13:35:24 Z vjudge1 From Hacks to Snitches (BOI21_watchmen) C++17
0 / 100
19 ms 14548 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn=250000+10;
vector<int>adj[maxn],allk[maxn];
int n,m,k,dp[130][maxn],inf=1e8+5,ki;
vector<int>bf;

int bad(int i){
    i++;
    i%=ki;
    return i;
}

void solve(int len=0){
    if(bf.size()==0){
        return ;
    }
    for(auto x:bf){
        dp[len%ki][x]=len;
    }
    vector<int>fake;
    for(auto x:bf){
        for(auto y:adj[x]){
            if(dp[bad(len)][y]==inf&&allk[1][bad(len)]!=y&&(allk[1][len%k]==y&&allk[1][bad(len)]==x)){
                fake.push_back(y);
                dp[bad(len)][y]=len+1;
            }
        }
    }
    swap(bf,fake);
    return solve(len+1);
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=0;i<130;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=inf;
        }
    }
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=1;i<=n;i++){
        adj[i].push_back(i);
    }
    cin>>k;
    for(int i=1;i<=k;i++){
        cin>>ki;
        allk[i].resize(ki);
        for(int j=0;j<ki;j++){
            cin>>allk[i][j];
        }
    }
    bf.push_back(1);
    solve();
    int res=inf;
    for(int i=0;i<ki;i++){
        res=min(res,dp[i][n]);
    }
    cout<<res<<"\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 14548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 14512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 14512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 14512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 14548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 14548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 14548 KB Output isn't correct
2 Halted 0 ms 0 KB -