/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main
(String[] args
) { int nameLength = 20;
int textSize = 50;
for (int i = 0; i < aTest.length; i++) {
aTest[i] = generateString(test, "ABCDEFGHIJKLMNOPQRSTUVWXYZ ", nameLength);
}
for (int i = 0; i < bTest.length; i++) {
int x = rand.nextInt(aTest.length);
bTest[i] = aTest[x] + ": " + generateString(test, "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%&*()_+", textSize);
}
long before
= System.
currentTimeMillis(); System.
out.
print(printTextPerRole
(aTest, bTest
)); System.
out.
println((System.
currentTimeMillis() - before
) + "ms.");// 8 sec(!)
}
char[] text = new char[length];
for (int i = 0; i < length; i++) {
text[i] = characters.charAt(rng.nextInt(characters.length()));
}
}
StringBuilder output = new StringBuilder("");
output.append(role + ":\n");
for (int i = 0; i < textLines.length; i++) {
if (textLines[i].startsWith(role)) {
output.append(i + 1 + ") ");
output.append(textLines[i].substring(role.length() + 2));
output.append("\n");
}
}
output.append("\n");
}
return output.toString();
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIFN0cmluZ1tdIGFUZXN0ID0gbmV3IFN0cmluZ1s1XTsgICAgLy8xMCByb2xlcwogICAgICAgIFN0cmluZ1tdIGJUZXN0ID0gbmV3IFN0cmluZ1s1MF07IC8vIDUwayBzdHJpbmdzCiAgICAgICAgUmFuZG9tIH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sZW5ndGhdOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgdGV4dFtpXSA9IGNoYXJhY3RlcnMuY2hhckF0KHJuZy5uZXh0SW50KGNoYXJhY3RlcnMubGVuZ3RoKCkpKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIG5ldyBTdHJpbmcodGV4dCk7CiAgICB9CgogICAgc3RhdGljIHByaXZhdGUgU3RyaW5nIHByaW50VGV4dFBlclJvbGUoU3RyaW5nW10gcm9sZXMsIFN0cmluZ1tdIHRleHRMaW5lcykgewogICAgICAgIFN0cmluZ0J1aWxkZXIgb3V0cHV0ID0gbmV3IFN0cmluZ0J1aWxkZXIoIiIpOwogICAgICAgIGZvciAoU3RyaW5nIHJvbGUgOiByb2xlcykgewogICAgICAgICAgICBvdXRwdXQuYXBwZW5kKHJvbGUgKyAiOlxuIik7CiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgdGV4dExpbmVzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICBpZiAodGV4dExpbmVzW2ldLnN0YXJ0c1dpdGgocm9sZSkpIHsKICAgICAgICAgICAgICAgICAgICBvdXRwdXQuYXBwZW5kKGkgKyAxICsgIikgIik7CiAgICAgICAgICAgICAgICAgICAgb3V0cHV0LmFwcGVuZCh0ZXh0TGluZXNbaV0uc3Vic3RyaW5nKHJvbGUubGVuZ3RoKCkgKyAyKSk7CiAgICAgICAgICAgICAgICAgICAgb3V0cHV0LmFwcGVuZCgiXG4iKTsKCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgb3V0cHV0LmFwcGVuZCgiXG4iKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIG91dHB1dC50b1N0cmluZygpOwogICAgfQp9