Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.ArrayList;
- import java.util.List;
- public class Main {
- public static void main(String[] args) {
- contest3();
- }
- public static void contest3() {
- try {
- byte[] buf = new byte[10];
- int index = -1;
- int v;
- while ((v = System.in.read()) != 10 && v != 13) {
- buf[++index] = (byte) v;
- }
- if (v == 13) System.in.read(); // if CR LF used, read LF
- byte[] numberBytes = new byte[index + 1];
- System.arraycopy(buf, 0, numberBytes, 0, index + 1);
- int size = Integer.parseInt(new String(numberBytes));
- if (size == 0) return;
- char[] previousMass = {'!'}; // Что точто не повторялось
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < size; i++) {
- char[] tmpCurrentMass = new char[32];
- int currentMassIndex = 0;
- while (true) {
- int currentByte;
- if ((currentByte = System.in.read()) >= '!' && currentByte <= '}') {
- tmpCurrentMass[currentMassIndex] = (char) currentByte;
- currentMassIndex++;
- } else break;
- }
- char[] currentMass = new char[currentMassIndex];
- System.arraycopy(tmpCurrentMass, 0, currentMass, 0, currentMassIndex);
- if (currentMass.length == previousMass.length) {
- boolean isContinue = false;
- for (int i1 = 0; i1 < currentMass.length; i1++) {
- if (currentMass[i1] != previousMass[i1])
- isContinue = true;
- }
- if (!isContinue) continue;
- }
- previousMass = currentMass;
- for (int i1 = 0; i1 < currentMass.length; i1++) {
- stringBuilder.append(currentMass[i1]);
- }
- stringBuilder.append('\n');
- if (i % 250 == 0) System.gc();
- }
- System.out.print(stringBuilder.toString());
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement