Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6. using System.Collections;
  7.  
  8. namespace BK
  9. {
  10. class fc
  11. {
  12. private int MAX;
  13. private int[][] WuT;
  14. public fc() { }
  15. private Stack<int> CompSub;
  16. public fc(int[][] test)
  17. {
  18. CompSub = new Stack<int>();
  19. MAX = 0;
  20. WuT = test;
  21. List<int> NotUsedSet = new List<int>();//candidates
  22. List<int> UsedSet = new List<int>();
  23. for (int i = 0; i < WuT.GetLength(0); i++)
  24. {
  25. NotUsedSet.Add(i);
  26. }
  27. function(NotUsedSet, UsedSet);
  28. StreamWriter SW = new StreamWriter("clique.out");
  29. SW.WriteLine(MAX);
  30. SW.Close();
  31. }
  32. private List<int> RemoveFrom(int v, List<int> ToRemove)
  33. {
  34. var s = from q in ToRemove
  35. where WuT[v].Contains(q)
  36. select q;
  37. return s.ToList();
  38. }
  39.  
  40. private void function(List<int> NotUsedSet, List<int> UsedSet)
  41. {
  42. while (NotUsedSet.Count != 0)
  43. {
  44. int v = NotUsedSet.First();
  45. CompSub.Push(v);
  46. List<int> NewUsedSet = UsedSet;
  47. List<int> NewNotUsedSet = NotUsedSet;
  48. NewNotUsedSet = RemoveFrom(v, NewNotUsedSet);
  49. NewUsedSet = RemoveFrom(v, NewUsedSet);
  50. if (NewNotUsedSet.Count == 0 && NewUsedSet.Count == 0)
  51. {
  52. MAX = CompSub.Count > MAX ? CompSub.Count : MAX;
  53. }
  54. else
  55. {
  56. function(NewNotUsedSet, NewUsedSet);
  57. }
  58. int qwe = CompSub.Pop();
  59. NotUsedSet.Remove(v);
  60. UsedSet.Add(v);
  61. }
  62. }
  63. class Program
  64. {
  65. static void Main(string[] args)
  66. {
  67. StreamReader SR = new StreamReader("clique.in");
  68. int n = int.Parse(SR.ReadLine());
  69. int[][] w0t = new int[n][];
  70. for (int i = 0; i < n; i++)
  71. {
  72. string[] line = SR.ReadLine().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  73. int size = int.Parse(line[0]);
  74. w0t[i] = new int[size];
  75. for (int k = 0; k < line.Length - 1; k++)
  76. {
  77. int temp = int.Parse(line[k + 1]);
  78. w0t[i][k] = temp;
  79. }
  80. }
  81. new fc(w0t);
  82. }
  83. }
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement