fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7.  
  8. namespace Кол_во_циклов_в_графе_1_
  9. {
  10. class Program
  11. {
  12. public static int vertex_count;
  13. public static int edge_count;
  14. public static int[,] Graph;
  15. public static int Amount = 0;
  16. public static int[] cnt;
  17.  
  18. static void Main(string[] args)
  19. {
  20. int n1, n2;
  21. string[] lines = File.ReadAllLines("graph.txt");
  22. string[] str = lines[0].Split(' ');
  23. vertex_count = Int32.Parse(str[0]);
  24. edge_count = Int32.Parse(str[1]);
  25.  
  26. Graph = new int[vertex_count, edge_count];
  27.  
  28. for (int k = 1; k < lines.Length; k++) {
  29. string[] hstr = lines[k].Split(' ');
  30. n1 = Int32.Parse(hstr[0]);
  31. n2 = Int32.Parse(hstr[1]);
  32. Graph[n1-1, n2-1] = 1;
  33. Graph[n2-1, n1-1] = 1;
  34.  
  35. }
  36. for (int i = 0; i < vertex_count; i++) {
  37. for (int j = 0; j < edge_count; j++) {
  38. Console.Write(Graph[i, j] + " ");
  39. }
  40. Console.WriteLine();
  41. }
  42. Console.WriteLine();
  43.  
  44. cnt = new int[vertex_count];
  45.  
  46. for (int i = 0; i < vertex_count; i++) {
  47. bool[] Use = new bool[vertex_count];
  48. for(int j = 0; j < edge_count; j++) {
  49.  
  50. Use[j] = false;
  51. }
  52. Use[i] = true;
  53. DFS(Use, i, i, 0);
  54. }
  55.  
  56. int y = 0;
  57. string s;
  58. for (int i = 2; i < vertex_count; i++) {
  59. y = cnt[i]/(i*2);
  60. s = "cnt[" + Convert.ToString(i) + "]: " + Convert.ToString(y);
  61. Console.WriteLine(s);
  62. }
  63. Console.ReadKey();
  64. }
  65. public static void DFS (bool []use, int k, int anc, int wave)
  66. {
  67. if (Graph[k, anc] != 0) cnt[wave+1]++;
  68. use[k] = true;
  69. for(int i = 0; i < vertex_count; i++)
  70. {
  71. if (!use[i] && Graph[k,i] != 0)
  72. {
  73. use[i] = true;
  74. DFS(use, i, anc, wave + 1);
  75. use[i] = false;
  76. }
  77. }
  78. }
  79. }
  80. }
  81.  
Runtime error #stdin #stdout #stderr 0.03s 27040KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Unhandled Exception:
System.IO.FileNotFoundException: Could not find file "/home/l8RxEd/graph.txt".
File name: '/home/l8RxEd/graph.txt'
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0 
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <filename unknown>:0 
  at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) [0x00000] in <filename unknown>:0 
  at System.IO.StreamReader..ctor (System.String path) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (string)
  at System.IO.File.OpenText (System.String path) [0x00000] in <filename unknown>:0 
  at System.IO.File.ReadAllLines (System.String path) [0x00000] in <filename unknown>:0 
  at Кол_во_циклов_в_графе_1_.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not find file "/home/l8RxEd/graph.txt".
File name: '/home/l8RxEd/graph.txt'
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0 
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <filename unknown>:0 
  at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) [0x00000] in <filename unknown>:0 
  at System.IO.StreamReader..ctor (System.String path) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (string)
  at System.IO.File.OpenText (System.String path) [0x00000] in <filename unknown>:0 
  at System.IO.File.ReadAllLines (System.String path) [0x00000] in <filename unknown>:0 
  at Кол_во_циклов_в_графе_1_.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0