Submission #311544
Source Code Expand
using System; using System.Collections.Generic; using System.Linq; using System.Text; class B1 { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); int n = int.Parse(str[0]); int m = int.Parse(str[1]); var children = new List<int>[n]; for (int i = 0; i < n; i++) children[i] = new List<int>(); for (int i = 0; i < m; i++) { string[] s = Console.ReadLine().Split(' '); int x = int.Parse(s[0]) - 1; int y = int.Parse(s[1]) - 1; children[x].Add(y); children[y].Add(x); } int need = 0; var remaining = new List<int>(Enumerable.Range(0, n)); while (remaining.Count > 0) { int start = remaining.First(); var queue = new Queue<int>(n); queue.Enqueue(start); while (queue.Count > 0) { int node = queue.Dequeue(); remaining.Remove(node); var next = children[node].Intersect(remaining); foreach (int index in next) { queue.Enqueue(index); } } need++; } Console.WriteLine(need - 1); Console.ReadLine(); } }
Submission Info
Submission Time | |
---|---|
Task | B - 道路工事 |
User | paralleltree |
Language | C# (Mono 2.10.8.1) |
Score | 0 |
Code Size | 1380 Byte |
Status | TLE |
Exec Time | 2041 ms |
Memory | 36552 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt |
All | 0.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0.txt | AC | 148 ms | 10300 KB |
1.txt | AC | 146 ms | 10356 KB |
10.txt | AC | 153 ms | 10316 KB |
11.txt | AC | 148 ms | 10292 KB |
12.txt | AC | 199 ms | 10584 KB |
13.txt | AC | 206 ms | 10512 KB |
14.txt | AC | 203 ms | 10508 KB |
15.txt | TLE | 2015 ms | 15360 KB |
16.txt | TLE | 2035 ms | 23108 KB |
17.txt | TLE | 2036 ms | 22980 KB |
18.txt | TLE | 2041 ms | 22992 KB |
19.txt | TLE | 2038 ms | 36552 KB |
2.txt | AC | 144 ms | 10384 KB |
3.txt | AC | 141 ms | 10368 KB |
4.txt | AC | 143 ms | 10280 KB |
5.txt | AC | 150 ms | 10376 KB |
6.txt | AC | 148 ms | 10376 KB |
7.txt | AC | 143 ms | 10372 KB |
8.txt | AC | 147 ms | 10280 KB |
9.txt | AC | 149 ms | 10376 KB |
sample1.txt | AC | 144 ms | 10348 KB |
sample2.txt | AC | 147 ms | 10372 KB |