ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1496. Spammer

Axmadjon Wrong answer test 3 in Java 1.7 please help me [1] // Problem 1496. Spammer 6 May 2014 19:03
import java.util.Arrays;
import java.util.Scanner;

public class _1496 {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int amount = s.nextInt();
        if (amount == 0) System.out.println("0");
        else {
            String[] source = new String[amount];
            String[] uniT = new String[amount];
            int j = 0;
            int count = 0;
            for (int i = 0; i < amount; i++) {
                source[i] = s.nextLine();
            }
            Arrays.sort(source);
            uniT[0] = source[0];

            for (int i = 0; i < amount; i++) {
                if (source[i].equals(uniT[j]) != true) {
                    j++;
                    uniT[j] = source[i];
                }
            }
            for (int i = 0; i <= j; i++) {
                count = 0;
                for (int k = 0; k < amount; k++) {
                    if (source[k].equals(uniT[i])) {
                        count++;
                    }
                }
                if (count > 1) {
                    System.out.println(uniT[i]);
                }
            }
        }
    }
}
You have to change Output in case of empty solution from "0" to Empty string. It will solve your problem