Skip to content

Instantly share code, notes, and snippets.

@ABeltramo
Created March 13, 2016 12:05
Show Gist options
  • Save ABeltramo/64559e6aefc89059996d to your computer and use it in GitHub Desktop.
Save ABeltramo/64559e6aefc89059996d to your computer and use it in GitHub Desktop.
Torero Escamillo
struct indumento{
bool indossabile;
vector<int> lista;
indumento():indossabile(true){}
};
int N,M,Q,non_indossabili;
indumento indumenti[100000];
void propaga(int n){
if (indumenti[n].indossabile == false)
return;
indumenti[n].indossabile = false;
non_indossabili++;
for (int j = 0; j < indumenti[n].lista.size(); j++)
propaga(indumenti[n].lista[j]);
}
int main(){
ifstream in("input.txt");
ofstream out("output.txt");
in >> N >> M >> Q;
for (int i=0; i < M; i++) {
int r,s;
in >> r >> s;
indumenti[r].lista.push_back(s);
}
propaga(Q);
out << N - non_indossabili << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment