Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Collections;
- namespace BK
- {
- class fc
- {
- private int MAX;
- private int[][] WuT;
- public fc() { }
- private Stack<int> CompSub;
- public fc(int[][] test)
- {
- CompSub = new Stack<int>();
- MAX = 0;
- WuT = test;
- List<int> NotUsedSet = new List<int>();//candidates
- List<int> UsedSet = new List<int>();
- for (int i = 0; i < WuT.GetLength(0); i++)
- {
- NotUsedSet.Add(i);
- }
- function(NotUsedSet, UsedSet);
- StreamWriter SW = new StreamWriter("clique.out");
- SW.WriteLine(MAX);
- SW.Close();
- }
- private List<int> RemoveFrom(int v, List<int> ToRemove)
- {
- var s = from q in ToRemove
- where WuT[v].Contains(q)
- select q;
- return s.ToList();
- }
- private void function(List<int> NotUsedSet, List<int> UsedSet)
- {
- while (NotUsedSet.Count != 0)
- {
- int v = NotUsedSet.First();
- CompSub.Push(v);
- List<int> NewUsedSet = UsedSet;
- List<int> NewNotUsedSet = NotUsedSet;
- NewNotUsedSet = RemoveFrom(v, NewNotUsedSet);
- NewUsedSet = RemoveFrom(v, NewUsedSet);
- if (NewNotUsedSet.Count == 0 && NewUsedSet.Count == 0)
- {
- MAX = CompSub.Count > MAX ? CompSub.Count : MAX;
- }
- else
- {
- function(NewNotUsedSet, NewUsedSet);
- }
- int qwe = CompSub.Pop();
- NotUsedSet.Remove(v);
- UsedSet.Add(v);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- StreamReader SR = new StreamReader("clique.in");
- int n = int.Parse(SR.ReadLine());
- int[][] w0t = new int[n][];
- for (int i = 0; i < n; i++)
- {
- string[] line = SR.ReadLine().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
- int size = int.Parse(line[0]);
- w0t[i] = new int[size];
- for (int k = 0; k < line.Length - 1; k++)
- {
- int temp = int.Parse(line[k + 1]);
- w0t[i][k] = temp;
- }
- }
- new fc(w0t);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement