|
|
вернуться в форумWrong Answer on Test #16 What is Test #16? Please someone help! Re: Wrong Answer on Test #16 Послано Mewtwo 16 апр 2017 19:08 What is Test #16? Please someone help! Same here... got stuck in Test-16 . Re: Wrong Answer on Test #16 Послано fengbo 9 дек 2018 21:25 so why did you get the WA16? Re: Wrong Answer on Test #16 Послано Tobi 14 сен 2019 01:26 Well maybe someone gonna read this but i got WA #16 cause my logic was wrong. i thought that i need to check if i studied any of prerequisite BUT i must check if i studied ALL OF them. maybe my code would help idk #include <iostream> #include <vector> using namespace std; int N, M, a[(int)1e3 + 5], b, c; bool visited[(int)1e3 + 5], flag, ans = true; vector <vector <int> > adj((int)1e3 + 5); int main() { cin >> N >> M; while(M--) cin >> b >> c, adj[c].push_back(b); for(int i = 0; i < N;++i) { cin >> a[i]; flag = true; visited[a[i]] = true; if(adj[a[i]].empty()) continue; for(int j = 0; j < adj[a[i]].size();++j) if(!visited[adj[a[i]][j]]) flag = false; if(!flag) ans = false; } if(!ans) cout <<"NO"; else cout << "YES"; } |
|
|