Search found 4 matches

by uohzxela
Fri Jan 09, 2015 5:26 am
Forum: Volume 5 (500-599)
Topic: 599 - The Forrest for the Trees
Replies: 18
Views: 8239

Re: 599 - The Forrest for the Trees

Just got AC for the problem. Turns out you don't need to implement cycle-finding for your DFS (DFS with cycle-finding will give WA). Just a simple DFS with coloring will do; a tree will contain colored nodes. Any white node in adjacency list with an empty list is an acorn. Be sure to add edge twice ...
by uohzxela
Sun Jan 04, 2015 3:13 pm
Forum: Volume 119 (11900-11999)
Topic: 11991 - Easy Problem from Rujia Liu?
Replies: 32
Views: 10102

Re: 11991 - Easy Problem from Rujia Liu?

I'll appreciate it if you guys can give me hint how to optimize my Java solution. I'm sure the algorithm is asymptotically performant (I followed brianfry's suggestion); I think I/O is the bottleneck here. I ended up using BufferedReader and StringTokenizer but still TLE. Any ideas? import
by uohzxela
Fri Jan 02, 2015 12:47 am
Forum: Volume 119 (11900-11999)
Topic: 11988 - Broken Keyboard (a.k.a. Beiju Text)
Replies: 27
Views: 10145

Re: 11988 - Broken Keyboard (a.k.a. Beiju Text)

Hey guys, need your help to optimize my Java solution. I used a linked list (Java standard, doubly linked list) and an iterator for indexing when the HOME key is pressed. I'm pretty sure the operations following both HOME and END keys are O(1). Following END key, beijuText.add(c) is O(1) since the l...
by uohzxela
Thu Jan 01, 2015 2:53 pm
Forum: Volume 102 (10200-10299)
Topic: 10258 - Contest Scoreboard
Replies: 87
Views: 35383

Re: 10258 - Contest Scoreboard

import; import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.TreeMap; class Main { public static void main(String args[]) { PrintWriter out = new PrintWriter(System.out); Scanner sc = new Scanner(; int ...

Go to advanced search