ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1671. Anansi's Cobweb

TLE#9 C# how make it faster? =(
Posted by Shamov Roman 24 Nov 2020 06:50
Can someone help how to make C# code faster?
Here is my code:

using System;
using System.Collections.Generic;
class Program
{
static int countCut(List<int>[] nods, List<int> uncheckedNodes)
{
int next = 0;
int count = 0;
do
{
count++;
watchCut(nods, uncheckedNodes, next);
if (uncheckedNodes.Count > 0)
next = uncheckedNodes[0];
else
next = -1;
} while (next != -1);
return count;
}
static void watchCut(List<int>[] nods, List<int> uncheckedNodes, int node)
{
uncheckedNodes.Remove(node);
for (int i = 0; i < nods[node].Count; i++)
{
if (uncheckedNodes.Contains(nods[node][i]))
watchCut(nods, uncheckedNodes, nods[node][i]);
}
}
static void Main(string[] args)
{
int N, M;
N = Convert.ToInt32(inp_NM[0]);
M = Convert.ToInt32(inp_NM[1]);
int[,] threads = new int[M, 2];
List<int>[] nods = new List<int>[N];
for (int i = 0; i < N; i++) nods[i] = new List<int>();
for (int i = 0; i < M; i++)
{
}
int Q;
int[] cuts = new int[Q];
for (int i = 0; i < Q; i++)
{
cuts[i] = Convert.ToInt32(inp_tear[i]) - 1;
}
for (int i = 0; i < Q; i++)
{