ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1280. Topological Sorting

Wrong Answer on Test #16
Posted by Shabab Karim 26 Aug 2015 12:15
What is Test #16? Please someone help!
Re: Wrong Answer on Test #16
Posted by Mewtwo 16 Apr 2017 19:08
Shabab Karim wrote 26 August 2015 12:15
What is Test #16? Please someone help!


Same here... got stuck in Test-16 .
Re: Wrong Answer on Test #16
Posted by fengbo 9 Dec 2018 21:25
so why did you get the WA16?
Re: Wrong Answer on Test #16
Posted by Tobi 14 Sep 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";
}