| Task: | Conversation Log |
| Sender: | lazycoder |
| Submission time: | 2015-11-25 19:22:11 +0200 |
| Language: | Java |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.17 s | details |
| #2 | WRONG ANSWER | 0.20 s | details |
| #3 | ACCEPTED | 0.33 s | details |
| #4 | WRONG ANSWER | 0.77 s | details |
| #5 | WRONG ANSWER | 0.78 s | details |
| #6 | TIME LIMIT EXCEEDED | -- | details |
| #7 | WRONG ANSWER | 0.18 s | details |
| #8 | WRONG ANSWER | 0.18 s | details |
| #9 | ACCEPTED | 0.17 s | details |
Code
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
public class Main {
static HashMap<String, String> words = new HashMap();
public static
<T extends Comparable<? super T>> List<T> asSortedList(Collection<T> c) {
List<T> list = new ArrayList<T>(c);
Collections.sort(list, Collections.reverseOrder());
return list;
}
public static void main(String args[]) throws IOException {
int N, cnt;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String inp;
N = Integer.parseInt(br.readLine());
String lines[] = new String[N];
for (int i = 0; i < N; i++) {
lines[i] = br.readLine();
}
Arrays.sort(lines);
String fUser = "";
for (int i = 0; i < N; i++) {
String input[] = lines[i].split(" ");
if (i == 0) {
fUser = input[0];
}
for (int j = 1; j < input.length; j++) {
if (words.containsKey(input[j])) {
cnt = Integer.parseInt(words.get(input[j]).split(":")[0]) + 1;
words.put(input[j], cnt + ":" + input[j]);
} else if (input[0].equals(fUser)) {
words.put(input[j], "1:" + input[j]);
}
}
}
Collection<String> unsorted = words.values();
List<String> sorted = Main.asSortedList(unsorted);
if (!sorted.isEmpty()) {
for (String sorted1 : sorted) {
System.out.println(sorted1.split(":")[1]);
}
} else {
System.out.println("ALL CLEAR");
}
}
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 4 user1 chomp chomp chomp chomp ... |
| correct output |
|---|
| chomp |
| user output |
|---|
| chomp |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 3 user1 doubledutch double doubl... |
| correct output |
|---|
| double doubledutch dutch |
| user output |
|---|
| doubledutch double dutch |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 10000 jli double mthorpe tastic rjh pneumonoultramicroscopicsi... |
| correct output |
|---|
| pneumonoultramicroscopicsilico... |
| user output |
|---|
| pneumonoultramicroscopicsilico... |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 10000 dwsozemhmiupnsnisans s i u a y... |
| correct output |
|---|
| ALL CLEAR |
| user output |
|---|
| v u o f k ... |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 100 ntgvyctezqvnefwcxhqj e o b r v... |
| correct output |
|---|
| k x g i l ... |
| user output |
|---|
| k x g i l ... |
Test 6
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 2 ukzoyurigzzhuxnssizv i m n r a... |
| correct output |
|---|
| m e f u n ... |
| user output |
|---|
| (empty) |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 3 James gobble de gook Bill gobble james de gook |
| correct output |
|---|
| ALL CLEAR |
| user output |
|---|
| gobble |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 5 user1 hello world user2 foo bar user3 baz quux user4 ear wig ... |
| correct output |
|---|
| ALL CLEAR |
| user output |
|---|
| world hello |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 3 user1 jibble jibble tastic user2 tastic jibble jibble user3 jibble tastic jibble |
| correct output |
|---|
| jibble tastic |
| user output |
|---|
| jibble tastic |
