Submission #7619032


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class FordFulkerson
{
    class Edge {
	public int to, cap, rev;
	public Edge(int _to, int _cap, int _rev)
	{
	    to = _to; cap = _cap; rev = _rev;
	}
    }

    List<Edge>[] G;
    bool[] used;
    int MAX_V;

    public void AddEdge(int from, int to, int cap)
    {
	G[from].Add(new Edge(to, cap, G[to].Count));
	G[to].Add(new Edge(from, 0, G[from].Count - 1));
    }
    
    int dfs (int v, int t, int f)
    {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].Count; i++)
	{
	    Edge e = G[v][i];
	    if (!used[e.to] && e.cap > 0)
	    {
		int d = dfs(e.to, t, Math.Min(f, e.cap));
		if (d > 0)
		{
		    e.cap -= d;
		    G[e.to][e.rev].cap += d;
		    return d;
		}
	    }
	}
	return 0;
    }

    public int MaxFlow(int s, int t)
    {
	int flow = 0;
	while (true)
	{
	    used = new bool[MAX_V];
	    int f = dfs(s, t, 1000000000);
	    if (f == 0) return flow;
	    flow += f;
	}
    }

    public FordFulkerson(int maxv)
    {
	MAX_V = maxv;
	G = new List<Edge>[MAX_V];
	for (int i = 0; i < MAX_V; i++)
	    G[i] = new List<Edge>();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], g = tmp[1], e = tmp[2];

	int[] marked = ReadIntArray();

	var mf = new FordFulkerson(n+1);

	for (int i = 0; i < e; i++)
	{
	    tmp = ReadIntArray();
	    int f = tmp[0], t = tmp[1];
	    mf.AddEdge(f, t, 1);
	}

	foreach (int x in marked)
	{
	    mf.AddEdge(x, n, 1);
	}

	WriteLine(mf.MaxFlow(0, n));
    }
}

Submission Info

Submission Time
Task D - 浮気予防
User unnohideyuki
Language C# (Mono 4.6.2.0)
Score 0
Code Size 1874 Byte
Status RE
Exec Time 31 ms
Memory 15444 KB

Judge Result

Set Name part All
Score / Max Score 0 / 99 0 / 1
Status
AC × 19
WA × 5
RE × 3
AC × 39
WA × 19
RE × 3
Set Name Test Cases
part test_01_AB.txt, test_02_AB.txt, test_03_AB.txt, test_04_AB.txt, test_05_AB.txt, test_06_AB.txt, test_07_AB.txt, test_08_AB.txt, test_09_AB.txt, test_10_AB.txt, test_11_AB.txt, test_12_AB.txt, test_13_AB.txt, test_14_AB.txt, test_15_AB.txt, test_16_AB.txt, test_17_AB.txt, test_18_AB.txt, test_19_AB.txt, test_20_AB.txt, test_21_AB.txt, test_22_AB.txt, test_23_AB.txt, test_24_AB.txt, test_25_AB.txt, test_41_AB.txt, test_47_AB.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, test_01_AB.txt, test_02_AB.txt, test_03_AB.txt, test_04_AB.txt, test_05_AB.txt, test_06_AB.txt, test_07_AB.txt, test_08_AB.txt, test_09_AB.txt, test_10_AB.txt, test_11_AB.txt, test_12_AB.txt, test_13_AB.txt, test_14_AB.txt, test_15_AB.txt, test_16_AB.txt, test_17_AB.txt, test_18_AB.txt, test_19_AB.txt, test_20_AB.txt, test_21_AB.txt, test_22_AB.txt, test_23_AB.txt, test_24_AB.txt, test_25_AB.txt, test_26_A.txt, test_27_A.txt, test_28_A.txt, test_29_A.txt, test_30_A.txt, test_31_A.txt, test_32_A.txt, test_33_A.txt, test_34_A.txt, test_35_A.txt, test_36_A.txt, test_37_A.txt, test_38_A.txt, test_39_A.txt, test_40_A.txt, test_41_AB.txt, test_42_A.txt, test_43_A.txt, test_44_A.txt, test_45_A.txt, test_46_A.txt, test_47_AB.txt, test_48_A.txt, test_49_A.txt, test_50_A.txt, test_51_A.txt
Case Name Status Exec Time Memory
sample_01.txt AC 24 ms 9300 KB
sample_02.txt AC 24 ms 11348 KB
sample_03.txt AC 24 ms 9300 KB
sample_04.txt AC 24 ms 11348 KB
sample_05.txt AC 24 ms 11348 KB
test_01_AB.txt RE 25 ms 10976 KB
test_02_AB.txt WA 25 ms 13396 KB
test_03_AB.txt WA 24 ms 11348 KB
test_04_AB.txt WA 24 ms 9300 KB
test_05_AB.txt AC 24 ms 11348 KB
test_06_AB.txt AC 24 ms 11348 KB
test_07_AB.txt AC 25 ms 13396 KB
test_08_AB.txt AC 25 ms 11348 KB
test_09_AB.txt AC 25 ms 13396 KB
test_10_AB.txt AC 25 ms 13396 KB
test_11_AB.txt WA 24 ms 9300 KB
test_12_AB.txt AC 24 ms 11348 KB
test_13_AB.txt AC 24 ms 9300 KB
test_14_AB.txt AC 24 ms 9300 KB
test_15_AB.txt AC 25 ms 13396 KB
test_16_AB.txt AC 24 ms 11348 KB
test_17_AB.txt AC 24 ms 11348 KB
test_18_AB.txt AC 24 ms 11348 KB
test_19_AB.txt AC 24 ms 11348 KB
test_20_AB.txt AC 24 ms 11348 KB
test_21_AB.txt AC 24 ms 9300 KB
test_22_AB.txt AC 24 ms 11348 KB
test_23_AB.txt AC 24 ms 11348 KB
test_24_AB.txt RE 24 ms 10976 KB
test_25_AB.txt AC 24 ms 11348 KB
test_26_A.txt WA 31 ms 13396 KB
test_27_A.txt WA 30 ms 11348 KB
test_28_A.txt AC 31 ms 13396 KB
test_29_A.txt AC 31 ms 15444 KB
test_30_A.txt AC 31 ms 13396 KB
test_31_A.txt WA 31 ms 15444 KB
test_32_A.txt WA 25 ms 11348 KB
test_33_A.txt AC 27 ms 11348 KB
test_34_A.txt AC 25 ms 11348 KB
test_35_A.txt WA 26 ms 11348 KB
test_36_A.txt WA 25 ms 11348 KB
test_37_A.txt WA 26 ms 11348 KB
test_38_A.txt WA 24 ms 9300 KB
test_39_A.txt WA 25 ms 13396 KB
test_40_A.txt AC 24 ms 11348 KB
test_41_AB.txt RE 24 ms 10976 KB
test_42_A.txt AC 27 ms 11348 KB
test_43_A.txt AC 25 ms 13396 KB
test_44_A.txt WA 26 ms 11348 KB
test_45_A.txt WA 25 ms 13396 KB
test_46_A.txt WA 25 ms 13396 KB
test_47_AB.txt WA 25 ms 13396 KB
test_48_A.txt AC 25 ms 11348 KB
test_49_A.txt WA 24 ms 9300 KB
test_50_A.txt WA 25 ms 11348 KB
test_51_A.txt AC 25 ms 13396 KB