Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (Wrong Answer:, see below for the correct answer too)
- Problem: WORDLIST
- State: Wrong Answer
- Total score for this submission: 0
- Your code compiled successfully but produced the following warnings
- Test Case #0 for 2 points
- Wrong Answer
- Runtime: 0.152
- Test Case #1 for 2 points
- Wrong Answer
- Runtime: 0.176
- Test Case #2 for 2 points
- Wrong Answer
- Runtime: 0.232
- Test Case #3 for 2 points
- Wrong Answer
- Runtime: 0.224
- Test Case #4 for 2 points
- Wrong Answer
- Runtime: 0.572
- Test Case #5 for 2 points
- Wrong Answer
- Runtime: 0.56
- Test Case #6 for 2 points
- Wrong Answer
- Runtime: 0.492
- Test Case #7 for 2 points
- Wrong Answer
- Runtime: 1.1
- Test Case #8 for 2 points
- Wrong Answer
- Runtime: 1.152
- Test Case #9 for 2 points
- Wrong Answer
- Runtime: 1.724
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Scanner;
- /**
- * Created by aditya on 14-10-2014.
- */
- public class Main {
- public static void main(String args[]) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- ArrayList<String> lines = new ArrayList<String>();
- ArrayList<String> words = new ArrayList<String>();
- boolean once_entered = true;
- for (int i = 0; i < n; i++) {
- lines.add(i, scan.nextLine() + " ");
- }
- for (int i = 0; i < n; i++) {
- String word = "";
- for (int j = 0; j < lines.get(i).length(); j++) {
- char char_0 = lines.get(i).toLowerCase().charAt(j);
- if ((int) (char_0) >= (int) ('a') && (int) (char_0) <= (int) ('z')) {
- word += char_0;
- once_entered = false;
- } else if (!once_entered) {
- words.add(word);
- word = "";
- once_entered = true;
- }
- }
- }
- for (int i = 0; i < words.size(); i++) {
- for (int j = 0; j < words.size(); j++) {
- if (i == j) continue;
- else if (words.get(i).equals(words.get(j))) {
- words.remove(words.get(j));
- }
- }
- }
- Collections.sort(words);
- System.out.println(words.size());
- for (int i = 0; i < words.size(); i++) {
- System.out.println(words.get(i));
- }
- }
- }
- (Correct Answer:)
- Problem: WORDLIST
- State: Accepted
- Total score for this submission: 20
- Test Case #0 for 2 points
- Correct Answer
- Runtime: 0.156
- Test Case #1 for 2 points
- Correct Answer
- Runtime: 0.16
- Test Case #2 for 2 points
- Correct Answer
- Runtime: 0.212
- Test Case #3 for 2 points
- Correct Answer
- Runtime: 0.204
- Test Case #4 for 2 points
- Correct Answer
- Runtime: 0.524
- Test Case #5 for 2 points
- Correct Answer
- Runtime: 0.444
- Test Case #6 for 2 points
- Correct Answer
- Runtime: 0.456
- Test Case #7 for 2 points
- Correct Answer
- Runtime: 1.096
- Test Case #8 for 2 points
- Correct Answer
- Runtime: 1.54
- Test Case #9 for 2 points
- Correct Answer
- Runtime: 1.636
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Scanner;
- /**
- * Created by aditya on 14-10-2014.
- */
- public class Main {
- public static void main(String args[]) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- ArrayList<String> lines = new ArrayList<String>();
- ArrayList<String> words = new ArrayList<String>();
- ArrayList<String> words_2 = new ArrayList<String>();
- boolean once_entered = true;
- for (int i = 0; i < n; i++) {
- lines.add(i, scan.nextLine() + " ");
- }
- for (int i = 0; i < n; i++) {
- String word = "";
- for (int j = 0; j < lines.get(i).length(); j++) {
- char char_0 = lines.get(i).toLowerCase().charAt(j);
- if ( (char_0) >= ('a') && (char_0) <= ('z')) {
- word += char_0;
- once_entered = false;
- } else if (!once_entered) {
- words.add(word);
- word = "";
- once_entered = true;
- }
- }
- }
- for (int i = 0; i < words.size(); i++) {
- boolean contains =false;
- for(int j=0;j<words_2.size();j++){
- if(words_2.get(j).contentEquals(words.get(i)))
- contains=true;
- }
- if(!contains)
- words_2.add(words.get(i));
- }
- Collections.sort(words_2);
- System.out.println(words_2.size());
- for (int i = 0; i < words_2.size(); i++) {
- System.out.println(words_2.get(i));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement