Submission #748172

# Submission time Handle Problem Language Result Execution time Memory
748172 2023-05-25T13:39:59 Z vjudge1 From Hacks to Snitches (BOI21_watchmen) C++17
5 / 100
1024 ms 132548 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]){
          //  cout<<x<<" "<<y<<" "<<len<<" "<<allk[1][bad(len)]<<"\n";
            if(dp[bad(len)][y]==inf&&allk[1][bad(len)]!=y&&!(allk[1][len%ki]==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 Correct 113 ms 14164 KB Output is correct
2 Correct 957 ms 132548 KB Output is correct
3 Correct 911 ms 118700 KB Output is correct
4 Correct 914 ms 114760 KB Output is correct
5 Correct 8 ms 12884 KB Output is correct
6 Correct 915 ms 117184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 14180 KB Output is correct
2 Correct 911 ms 132528 KB Output is correct
3 Correct 830 ms 118752 KB Output is correct
4 Correct 1024 ms 114700 KB Output is correct
5 Correct 8 ms 12988 KB Output is correct
6 Correct 887 ms 117244 KB Output is correct
7 Incorrect 512 ms 97072 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 112 ms 14180 KB Output is correct
2 Correct 911 ms 132528 KB Output is correct
3 Correct 830 ms 118752 KB Output is correct
4 Correct 1024 ms 114700 KB Output is correct
5 Correct 8 ms 12988 KB Output is correct
6 Correct 887 ms 117244 KB Output is correct
7 Incorrect 512 ms 97072 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 112 ms 14180 KB Output is correct
2 Correct 911 ms 132528 KB Output is correct
3 Correct 830 ms 118752 KB Output is correct
4 Correct 1024 ms 114700 KB Output is correct
5 Correct 8 ms 12988 KB Output is correct
6 Correct 887 ms 117244 KB Output is correct
7 Incorrect 512 ms 97072 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 14164 KB Output is correct
2 Correct 957 ms 132548 KB Output is correct
3 Correct 911 ms 118700 KB Output is correct
4 Correct 914 ms 114760 KB Output is correct
5 Correct 8 ms 12884 KB Output is correct
6 Correct 915 ms 117184 KB Output is correct
7 Correct 112 ms 14180 KB Output is correct
8 Correct 911 ms 132528 KB Output is correct
9 Correct 830 ms 118752 KB Output is correct
10 Correct 1024 ms 114700 KB Output is correct
11 Correct 8 ms 12988 KB Output is correct
12 Correct 887 ms 117244 KB Output is correct
13 Incorrect 512 ms 97072 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 14164 KB Output is correct
2 Correct 957 ms 132548 KB Output is correct
3 Correct 911 ms 118700 KB Output is correct
4 Correct 914 ms 114760 KB Output is correct
5 Correct 8 ms 12884 KB Output is correct
6 Correct 915 ms 117184 KB Output is correct
7 Correct 112 ms 14180 KB Output is correct
8 Correct 911 ms 132528 KB Output is correct
9 Correct 830 ms 118752 KB Output is correct
10 Correct 1024 ms 114700 KB Output is correct
11 Correct 8 ms 12988 KB Output is correct
12 Correct 887 ms 117244 KB Output is correct
13 Incorrect 512 ms 97072 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 14164 KB Output is correct
2 Correct 957 ms 132548 KB Output is correct
3 Correct 911 ms 118700 KB Output is correct
4 Correct 914 ms 114760 KB Output is correct
5 Correct 8 ms 12884 KB Output is correct
6 Correct 915 ms 117184 KB Output is correct
7 Correct 112 ms 14180 KB Output is correct
8 Correct 911 ms 132528 KB Output is correct
9 Correct 830 ms 118752 KB Output is correct
10 Correct 1024 ms 114700 KB Output is correct
11 Correct 8 ms 12988 KB Output is correct
12 Correct 887 ms 117244 KB Output is correct
13 Incorrect 512 ms 97072 KB Output isn't correct
14 Halted 0 ms 0 KB -