using System using System Collections Generic using System Linq using

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication8
{
class Arcs
{
int[] heads;
int[] destination;
int[] nextArc;
public Arcs(int n, int m, int[] from, int[] to)
{
heads = new int[n];
destination = new int[m];
nextArc = new int[m];
for(int i = 0; i < heads.Length; ++i)
{
heads[i] = -1;
}
for(int i = 0; i < m; ++i)
{
AddArc(from[i], to[i], i);
}
}
void AddArc(int from, int to, int i)
{
nextArc[i] = heads[from];
destination[i] = to;
heads[from] = i;
}
}
class Program
{
static void Main(string[] args)
{
int n = 6, m = 5;
int[] from = new int []{ 0,0,0,0,0 };
int[] to = new int []{ 1, 2, 3, 4, 5 };
Arcs arcs = new Arcs(n,m, from, to);
}
}
}