What does "Special judge: No expected output available." mean?


  • 1
    R

    I am running to 32/35 test cases, and get the following error:
    What does "Special judge: No expected output available." mean?

    Output:
    []

    Expected:
    Special judge: No expected output available.

    Input:
    800, [[695,229],[199,149],[443,397],[258,247],[781,667],[350,160],[678,629],[467,166],[500,450],[477,107],[483,151],[792,785],[752,368],[659,623],[316,224],[487,268],[743,206],[552,211],[314,20],[720,196],[421,103],[493,288],[762,24],[528,318],[472,32],[684,502],[641,354],[586,480],[629,54],[611,412],[719,680],[733,42],[549,519],[697,316],[791,634],[546,70],[676,587],[460,58],[605,530],[617,579],[484,89],[571,482],[767,200],[555,547],[771,695],[624,542],[708,551],[432,266],[656,468],[724,317],[423,248],[621,593],[781,399],[535,528],[578,12],[770,549],[576,295],[318,247],[400,372],[465,363],[786,482],[441,398],[577,411],[524,30],[741,540],[459,59],[758,96],[550,89],[402,295],[476,336],[645,346],[750,116],[551,207],[343,226],[568,498],[530,228],[525,84],[507,128],[526,210],[535,381],[635,330],[654,535],[710,275],[397,213],[412,44],[131,70],[508,49],[679,223],[519,11],[626,286],[242,160],[778,199],[606,281],[226,16],[340,46],[578,127],[212,208],[674,343],[778,108], ......


  • 0
    S

    The same problem has occurred to me. And my bug is that I put course and its precourse in the reverse place when i create the graph.
    As follows:
    first, I have to creatr the graph.

     for(int i = 0; i<prerequisites.size(); i++) {
    			int course = prerequisites[i].first;//课程
    			int preCourse = prerequisites[i].second;//要求的先修课程
    			neighbours[course ].push_back(preCourse );//this setence has a bug!
    		}
    

    you can see, the last sentence is wrong, so i get the same reply of "Special judge: No expected output available."

    then i correct it

    for(int i = 0; i<prerequisites.size(); i++) {
    	int course = prerequisites[i].first;//课程
    	int preCourse = prerequisites[i].second;//要求的先修课程
    	// 对每一条边 v -> w ,此处就是preCourse->course
    	neighbours[preCourse].push_back(course);
    }
    

    and now it can AC

    Well, my code as follows:
    BFS:

    class Solution {
    public:
        vector<int> findOrder(int numCourses, vector<pair<int, int>>& prerequisites) 
    	{
    		// build the graph and compute in_degrees
    		vector<int>inDegree(numCourses, 0);
    		vector<vector<int> > neighbours(numCourses);
    
    		for(int i = 0; i < prerequisites.size(); ++i)
    		{
    			neighbours[prerequisites[i].second].push_back(prerequisites[i].first);
    			inDegree[prerequisites[i].first]++;
    		}
    
    		// find all in_degree==0, and mark them as visited(set inDegree to -1)
    		queue<int> inDegree0;
    		int count = 0;
    		for(int i = 0; i < numCourses; ++i)
    		{
    			if(inDegree[i] == 0)
    			{
    				inDegree0.push(i);
    				inDegree[i] = -1;
    				count++;
    			}
    		}
    
    		vector<int> res;
    		// pop a node from queue, decrease the degree of the neighbours and push the degree==0    
    		while(!inDegree0.empty())
    		{
    			int cur = inDegree0.front(); 
    			inDegree0.pop();
    			res.push_back(cur);
    			for(int i = 0; i < neighbours[cur].size(); ++i) 
    			{
    				inDegree[neighbours[cur][i]] --;
    				if(inDegree[neighbours[cur][i]] == 0)
    				{
    					count++;
    					inDegree0.push(neighbours[cur][i]);
    					inDegree[neighbours[cur][i]] = -1;
    				}
    			}
    		}
    		if(count != numCourses)
    			return vector<int>();
    		else
    			return res;
        }
    };
    

    DFS:

    class Solution2 {
    public:
    	vector<int> findOrder(int numCourses, vector<pair<int, int> >& prerequisites) 
    	{
    		vector<vector<int> > neighbours (numCourses, vector<int>());
    	
    		for(int i = 0; i<prerequisites.size(); i++) {
    			int course = prerequisites[i].first;
    			int preCourse = prerequisites[i].second;
    			neighbours[preCourse].push_back(course);
    		}
    
    		vector<bool> onpath (numCourses, false);
    		vector<bool> visited (numCourses, false);
    		vector<int> res;
    		for(int i = 0; i < numCourses; i++) 
    		{
    			if(getCourseDFS(res, neighbours, onpath, visited, i) == false)
    				return vector<int>();
    		}
    		reverse(res.begin(), res.end());
    		return res;
    	}
    
    	bool getCourseDFS(vector<int> &res, vector<vector<int> >& neighbours, vector<bool>& onpath, vector<bool>& visited, int node) 
    	{
    		if(onpath[node]) 
    			return false;
    		if(visited[node]) 
    			return true;
    
    		onpath[node] = true;
    		visited[node] = true;
    
    		for(int i = 0; i < neighbours[node].size(); i ++) {
    			if(getCourseDFS(res, neighbours, onpath, visited, neighbours[node][i]) == false)
    				return false;
    		}
    
    		res.push_back(node);
    		onpath[node] = false;
    		return true;
    	}
    };
    

    I am noe sure that your bug is the same as mine, but I wish it can help you!


  • 0
    Y

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.