using System; using System.Collections.Generic; namespace Dag{ class Program{ static bool able1to33 = true; struct Vertex{ public List outGoing; public List inGoing; } struct Graph{ public Vertex[] v; public Graph(int length){ v = new Vertex[length]; for(int i=0; i< length; i++){ v[i].outGoing = new List(); v[i].inGoing = new List(); } } public int length{ get {return v.Length;} } public override string ToString(){ String str=""; for(int i=0; i toMoveOut = new List(); foreach(int m in g.v[l].outGoing){ if(!visited[m]||finished[m]){ toMoveOut.Add(m); } } i--; foreach(int m in toMoveOut){ g.removeEdge(l,m); g.addEdge(k,m); } List toMoveIn = new List(); foreach(int m in g.v[l].inGoing){ if(!visited[m]||finished[m]){ toMoveIn.Add(m); } } foreach(int m in toMoveIn){ g.removeEdge(m,l); g.addEdge(m,k); } bool[] visited2 = new bool[g.v.Length]; if(able1to33){ able1to33 = fromToPossible(g,1-1,33-1,visited2,false); if(!able1to33){ Console.WriteLine($"The path from 1 to 33 became inpossible when k={k+1} and l={l+1}"); } //Console.WriteLine($"After removing the edge from {start+1} to {end+1} it is not possible to get from 33 to 11"); } }else{ } } finished[k] = true; } static void OptimalDFS(Graph g, bool[] visited, int[] optimal, int[] coins, bool[] noDeadEnd, int k){ visited[k] = true; //the finish can't be a dead end if(k+1== g.length){ noDeadEnd[k]=true; optimal[k] = coins[k]; } for(int i=0; i=0;k=new_k){ //Console.WriteLine(k); if(coins[k]==1) Console.Write($"{k+1} "); new_k =-1; for(int i=0; i l = new List(); int c =0; foreach(int p in path){ Console.WriteLine(c); c++; bool possible=false; for(int i=0; i<=l.Count;i++){ l.Insert(i,p); if(pathPossible(g,l.ToArray(),1)){ possible=true; break; }else{ l.RemoveAt(i); } } if(!possible){ Console.WriteLine($"Could not add {p} anywhere"); foreach(int i in l){ Console.Write($"{i} "); } return; } } Console.WriteLine("It is definitely possible here is the path:"); foreach(int p in l){ Console.Write($"{p} "); } } static void MainOld(){ string[] threeNumbers = Console.ReadLine().Split(' '); int n = Int32.Parse(threeNumbers[0]); int m = Int32.Parse(threeNumbers[1]); int s = Int32.Parse(threeNumbers[2]); Graph g = new Graph(n); for(int j =0; j