ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1269. Obscene Words Filter

Crash Where is my mistake?
Posted by behzodbek 15 Oct 2012 00:37
import java.io.IOException;
import java.util.*;

public class Main {

public static void main(String[] args) throws IOException  {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String S[] = new String[n];
for (int i = 0; i < n; i++) {
S[i] = sc.next();
}
int m = sc.nextInt();
String[] S2 = new String[m];
for (int i = 0; i < m; i++) {
}

int count = 0, tempcont = 0;
boolean isFineded = false;

for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {

StringTokenizer st = new StringTokenizer(S2[i]);
count -= tempcont;
tempcont = 0;
while (st.hasMoreTokens()) {
tempcont++;
String temp = st.nextToken();
if (isExits(temp, S[j])) {
count++;
isFineded = true;
System.out.println(i + 1 + " " + count);
} else {
count++;
}
}
}
tempcont = 0;
}

if (isFineded == false) {
System.out.println("Passed");
}

}
static boolean isExits(String src, String str) {
boolean bol=false;
if (str.length() > src.length()) {
return false;
} else if (str.equals(src)) {
return true;
} else {
for (int i = 0; i <= src.length() - str.length(); i++) {
if (str.equals(src.substring(i, i + str.length()))) {
bol=true;
}
}
return bol;
}

}
}