Created
March 13, 2016 12:05
-
-
Save ABeltramo/64559e6aefc89059996d to your computer and use it in GitHub Desktop.
Torero Escamillo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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