Diff
checker
Texto
Texto
Imagens
Documentos
Excel
Pastas
Legal
Enterprise
Aplicativo para desktop
Preços
Fazer login
Baixar o Diffchecker Desktop
Comparar texto
Encontre a diferença entre dois arquivos de texto
Ferramentas
Histórico
Editor live
Recolher inalteradas
Sem quebra de linha
Layout
Dividido
Unificado
Nível de detalhe
Inteligente
Palavra
Caractere
Realce de sintaxe
Escolher sintaxe
Ignorar
Transformar texto
Ir à primeira mudança
Editar entrada
Diffchecker Desktop
A maneira mais segura de usar o Diffchecker. Obtenha o aplicativo Diffchecker Desktop: seus diffs nunca saem do seu computador!
Obter Desktop
Untitled diff
Criado
há 11 anos
O diff nunca expira
Limpar
Exportar
Compartilhar
Explicar
8 remoções
Linhas
Total
Removido
Caracteres
Total
Removido
Para continuar usando este recurso, atualize para
Diff
checker
Pro
Ver preços
215 linhas
Copiar tudo
0 adições
Linhas
Total
Adicionado
Caracteres
Total
Adicionado
Para continuar usando este recurso, atualize para
Diff
checker
Pro
Ver preços
210 linhas
Copiar tudo
import java.io.*;
import java.io.*;
import java.util.*;
import java.util.*;
import java.math.*;
import java.math.*;
public class TicTac implements Runnable {
public class TicTac implements Runnable {
private static BufferedReader in;
private static BufferedReader in;
private static PrintWriter out;
private static PrintWriter out;
private static StringTokenizer st;
private static StringTokenizer st;
private static Random rnd;
private static Random rnd;
static class Pair {
static class Pair {
final int x, y;
final int x, y;
public Pair(int x, int y) {
public Pair(int x, int y) {
this.x = x;
this.x = x;
this.y = y;
this.y = y;
}
}
}
}
private void solve() throws IOException {
private void solve() throws IOException {
while (true) {
while (true) {
char[][] field = readField();
char[][] field = readField();
if (isOver(field))
if (isOver(field))
break;
break;
if (!isEmpty(field))
if (!isEmpty(field))
throw new AssertionError();
throw new AssertionError();
field[1][1] = 'x';
field[1][1] = 'x';
printField(field);
printField(field);
field = readField();
field = readField();
Pair corner = selectCorner(field);
Pair corner = selectCorner(field);
field[corner.x][corner.y] = 'x';
field[corner.x][corner.y] = 'x';
printField(field);
printField(field);
field = readField();
field = readField();
Pair opposite = new Pair(2 - corner.x, 2 - corner.y);
Pair opposite = new Pair(2 - corner.x, 2 - corner.y);
if (field[opposite.x][opposite.y] == '.') {
if (field[opposite.x][opposite.y] == '.') {
field[opposite.x][opposite.y] = 'x';
field[opposite.x][opposite.y] = 'x';
printField(field);
printField(field);
continue;
continue;
}
}
Pair support = selectSupport(field);
Pair support = selectSupport(field);
field[support.x][support.y] = 'x';
field[support.x][support.y] = 'x';
printField(field);
printField(field);
field = readField();
field = readField();
Pair last = selectLast(field);
Pair last = selectLast(field);
field[last.x][last.y] = 'x';
field[last.x][last.y] = 'x';
printField(field);
printField(field);
}
}
}
}
private boolean isEmpty(char[][] field) {
private boolean isEmpty(char[][] field) {
for (int i = 0; i <= 2; i++)
for (int i = 0; i <= 2; i++)
for (int j = 0; j <= 2; j++)
for (int j = 0; j <= 2; j++)
if (field[i][j] != '.')
if (field[i][j] != '.')
return false;
return false;
return true;
return true;
}
}
private Pair selectLast(char[][] field) {
private Pair selectLast(char[][] field) {
for (int x0 = 0; x0 <= 2; x0++) {
for (int x0 = 0; x0 <= 2; x0++) {
for (int y0 = 0; y0 <= 2; y0++) {
for (int y0 = 0; y0 <= 2; y0++) {
for (int x1 = 0; x1 <= 2; x1++) {
for (int x1 = 0; x1 <= 2; x1++) {
for (int y1 = 0; y1 <= 2; y1++) {
for (int y1 = 0; y1 <= 2; y1++) {
int dx = x1 - x0;
int dx = x1 - x0;
int dy = y1 - y0;
int dy = y1 - y0;
if (Math.abs(dx) + Math.abs(dy) == 0)
if (Math.abs(dx) + Math.abs(dy) == 0)
continue;
continue;
if (Math.abs(dx) > 1 || Math.abs(dy) > 1)
if (Math.abs(dx) > 1 || Math.abs(dy) > 1)
continue;
continue;
if (field[x0][y0] != 'x')
if (field[x0][y0] != 'x')
continue;
continue;
if (field[x1][y1] != 'x')
if (field[x1][y1] != 'x')
continue;
continue;
int x2 = x1 + dx, y2 = y1 + dy;
int x2 = x1 + dx, y2 = y1 + dy;
if (x2 >= 0 && x2 <= 2 && y2 >= 0 && y2 <= 2 && field[x2][y2] == '.') {
if (x2 >= 0 && x2 <= 2 && y2 >= 0 && y2 <= 2 && field[x2][y2] == '.') {
return new Pair(x2, y2);
return new Pair(x2, y2);
}
}
}
}
}
}
}
}
}
}
throw new AssertionError();
throw new AssertionError();
}
}
private Pair selectSupport(char[][] field) {
private Pair selectSupport(char[][] field) {
for (int x = 0; x <= 2; x++) {
for (int x = 0; x <= 2; x++) {
for (int y = 0; y <= 2; y++) {
for (int y = 0; y <= 2; y++) {
if ((x + y) % 2 == 1 && field[x][y] == '.') {
if ((x + y) % 2 == 1 && field[x][y] == '.') {
field[x][y] = 'x';
field[x][y] = 'x';
int ways = calcWays(field);
int ways = calcWays(field);
if (ways >= 2) {
if (ways >= 2) {
return new Pair(x, y);
return new Pair(x, y);
}
}
field[x][y] = '.';
field[x][y] = '.';
}
}
}
}
}
}
throw new AssertionError();
throw new AssertionError();
}
}
private int calcWays(char[][] field) {
private int calcWays(char[][] field) {
boolean[][] used = new boolean[3][3];
boolean[][] used = new boolean[3][3];
for (int x0 = 0; x0 <= 2; x0++) {
for (int x0 = 0; x0 <= 2; x0++) {
for (int y0 = 0; y0 <= 2; y0++) {
for (int y0 = 0; y0 <= 2; y0++) {
for (int x1 = 0; x1 <= 2; x1++) {
for (int x1 = 0; x1 <= 2; x1++) {
for (int y1 = 0; y1 <= 2; y1++) {
for (int y1 = 0; y1 <= 2; y1++) {
int dx = x1 - x0;
int dx = x1 - x0;
int dy = y1 - y0;
int dy = y1 - y0;
if (Math.abs(dx) + Math.abs(dy) == 0)
if (Math.abs(dx) + Math.abs(dy) == 0)
continue;
continue;
if (Math.abs(dx) > 1 || Math.abs(dy) > 1)
if (Math.abs(dx) > 1 || Math.abs(dy) > 1)
continue;
continue;
if (field[x0][y0] != 'x')
if (field[x0][y0] != 'x')
continue;
continue;
if (field[x1][y1] != 'x')
if (field[x1][y1] != 'x')
continue;
continue;
int x2 = x1 + dx, y2 = y1 + dy;
int x2 = x1 + dx, y2 = y1 + dy;
if (x2 >= 0 && x2 <= 2 && y2 >= 0 && y2 <= 2 && field[x2][y2] == '.') {
if (x2 >= 0 && x2 <= 2 && y2 >= 0 && y2 <= 2 && field[x2][y2] == '.') {
used[x2][y2] = true;
used[x2][y2] = true;
}
}
}
}
}
}
}
}
}
}
int res = 0;
int res = 0;
for (int i = 0; i <= 2; i++)
for (int i = 0; i <= 2; i++)
for (int j = 0; j <= 2; j++)
for (int j = 0; j <= 2; j++)
if (used[i][j])
if (used[i][j])
++res;
++res;
return res;
return res;
}
}
private Pair selectCorner(char[][] field) {
private Pair selectCorner(char[][] field) {
int[] xs = { 0, 2 }, ys = { 0, 2 };
int[] xs = { 0, 2 }, ys = { 0, 2 };
for (int x : xs)
for (int x : xs)
for (int y : ys) {
for (int y : ys) {
if (field[x][y] == '.')
if (field[x][y] == '.')
return new Pair(x, y);
return new Pair(x, y);
}
}
throw new AssertionError();
throw new AssertionError();
}
}
private void printField(char[][] field) {
private void printField(char[][] field) {
for (int i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
out.println(new String(field[i]));
out.println(new String(field[i]));
out.flush();
out.flush();
}
}
private char[][] readField() throws IOException {
private char[][] readField() throws IOException {
char[][] result = new char[3][];
char[][] result = new char[3][];
for (int i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
result[i] = nextToken().toCharArray();
result[i] = nextToken().toCharArray();
return result;
return result;
}
}
private boolean isOver(char[][] field) {
private boolean isOver(char[][] field) {
for (int i = 0; i <= 2; i++)
for (int i = 0; i <= 2; i++)
for (int j = 0; j <= 2; j++)
for (int j = 0; j <= 2; j++)
if (field[i][j] != 'x')
if (field[i][j] != 'x')
return false;
return false;
return true;
return true;
}
}
public static void main(String[] args) {
public static void main(String[] args) {
new TicTac().run();
new TicTac().run();
}
}
public void run() {
public void run() {
final String className = this.getClass().getName().toLowerCase();
final String className = this.getClass().getName().toLowerCase();
try {
try {
Copiar
Copiado
Copiar
Copiado
try {
in = new BufferedReader(new InputStreamReader(System.in));
in = new BufferedReader(new FileReader("input.txt"));
out = new PrintWriter(System.out);
out = new PrintWriter(new FileWriter("output.txt"));
} catch (FileNotFoundException e) {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
}
rnd = new Random();
rnd = new Random();
solve();
solve();
out.close();
out.close();
} catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace();
System.exit(1);
System.exit(1);
}
}
}
}
private String nextToken() throws IOException {
private String nextToken() throws IOException {
while (st == null || !st.hasMoreTokens()) {
while (st == null || !st.hasMoreTokens()) {
String line = in.readLine();
String line = in.readLine();
if (line == null)
if (line == null)
return null;
return null;
st = new StringTokenizer(line);
st = new StringTokenizer(line);
}
}
return st.nextToken();
return st.nextToken();
}
}
private int nextInt() throws IOException {
private int nextInt() throws IOException {
return Integer.parseInt(nextToken());
return Integer.parseInt(nextToken());
}
}
private long nextLong() throws IOException {
private long nextLong() throws IOException {
return Long.parseLong(nextToken());
return Long.parseLong(nextToken());
}
}
private double nextDouble() throws IOException {
private double nextDouble() throws IOException {
return Double.parseDouble(nextToken());
return Double.parseDouble(nextToken());
}
}
}
}
Diferenças salvas
Texto original
Abrir arquivo
import java.io.*; import java.util.*; import java.math.*; public class TicTac implements Runnable { private static BufferedReader in; private static PrintWriter out; private static StringTokenizer st; private static Random rnd; static class Pair { final int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } } private void solve() throws IOException { while (true) { char[][] field = readField(); if (isOver(field)) break; if (!isEmpty(field)) throw new AssertionError(); field[1][1] = 'x'; printField(field); field = readField(); Pair corner = selectCorner(field); field[corner.x][corner.y] = 'x'; printField(field); field = readField(); Pair opposite = new Pair(2 - corner.x, 2 - corner.y); if (field[opposite.x][opposite.y] == '.') { field[opposite.x][opposite.y] = 'x'; printField(field); continue; } Pair support = selectSupport(field); field[support.x][support.y] = 'x'; printField(field); field = readField(); Pair last = selectLast(field); field[last.x][last.y] = 'x'; printField(field); } } private boolean isEmpty(char[][] field) { for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2; j++) if (field[i][j] != '.') return false; return true; } private Pair selectLast(char[][] field) { for (int x0 = 0; x0 <= 2; x0++) { for (int y0 = 0; y0 <= 2; y0++) { for (int x1 = 0; x1 <= 2; x1++) { for (int y1 = 0; y1 <= 2; y1++) { int dx = x1 - x0; int dy = y1 - y0; if (Math.abs(dx) + Math.abs(dy) == 0) continue; if (Math.abs(dx) > 1 || Math.abs(dy) > 1) continue; if (field[x0][y0] != 'x') continue; if (field[x1][y1] != 'x') continue; int x2 = x1 + dx, y2 = y1 + dy; if (x2 >= 0 && x2 <= 2 && y2 >= 0 && y2 <= 2 && field[x2][y2] == '.') { return new Pair(x2, y2); } } } } } throw new AssertionError(); } private Pair selectSupport(char[][] field) { for (int x = 0; x <= 2; x++) { for (int y = 0; y <= 2; y++) { if ((x + y) % 2 == 1 && field[x][y] == '.') { field[x][y] = 'x'; int ways = calcWays(field); if (ways >= 2) { return new Pair(x, y); } field[x][y] = '.'; } } } throw new AssertionError(); } private int calcWays(char[][] field) { boolean[][] used = new boolean[3][3]; for (int x0 = 0; x0 <= 2; x0++) { for (int y0 = 0; y0 <= 2; y0++) { for (int x1 = 0; x1 <= 2; x1++) { for (int y1 = 0; y1 <= 2; y1++) { int dx = x1 - x0; int dy = y1 - y0; if (Math.abs(dx) + Math.abs(dy) == 0) continue; if (Math.abs(dx) > 1 || Math.abs(dy) > 1) continue; if (field[x0][y0] != 'x') continue; if (field[x1][y1] != 'x') continue; int x2 = x1 + dx, y2 = y1 + dy; if (x2 >= 0 && x2 <= 2 && y2 >= 0 && y2 <= 2 && field[x2][y2] == '.') { used[x2][y2] = true; } } } } } int res = 0; for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2; j++) if (used[i][j]) ++res; return res; } private Pair selectCorner(char[][] field) { int[] xs = { 0, 2 }, ys = { 0, 2 }; for (int x : xs) for (int y : ys) { if (field[x][y] == '.') return new Pair(x, y); } throw new AssertionError(); } private void printField(char[][] field) { for (int i = 0; i < 3; i++) out.println(new String(field[i])); out.flush(); } private char[][] readField() throws IOException { char[][] result = new char[3][]; for (int i = 0; i < 3; i++) result[i] = nextToken().toCharArray(); return result; } private boolean isOver(char[][] field) { for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2; j++) if (field[i][j] != 'x') return false; return true; } public static void main(String[] args) { new TicTac().run(); } public void run() { final String className = this.getClass().getName().toLowerCase(); try { try { in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter(new FileWriter("output.txt")); } catch (FileNotFoundException e) { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } rnd = new Random(); solve(); out.close(); } catch (IOException e) { e.printStackTrace(); System.exit(1); } } private String nextToken() throws IOException { while (st == null || !st.hasMoreTokens()) { String line = in.readLine(); if (line == null) return null; st = new StringTokenizer(line); } return st.nextToken(); } private int nextInt() throws IOException { return Integer.parseInt(nextToken()); } private long nextLong() throws IOException { return Long.parseLong(nextToken()); } private double nextDouble() throws IOException { return Double.parseDouble(nextToken()); } }
Texto alterado
Abrir arquivo
import java.io.*; import java.util.*; import java.math.*; public class TicTac implements Runnable { private static BufferedReader in; private static PrintWriter out; private static StringTokenizer st; private static Random rnd; static class Pair { final int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } } private void solve() throws IOException { while (true) { char[][] field = readField(); if (isOver(field)) break; if (!isEmpty(field)) throw new AssertionError(); field[1][1] = 'x'; printField(field); field = readField(); Pair corner = selectCorner(field); field[corner.x][corner.y] = 'x'; printField(field); field = readField(); Pair opposite = new Pair(2 - corner.x, 2 - corner.y); if (field[opposite.x][opposite.y] == '.') { field[opposite.x][opposite.y] = 'x'; printField(field); continue; } Pair support = selectSupport(field); field[support.x][support.y] = 'x'; printField(field); field = readField(); Pair last = selectLast(field); field[last.x][last.y] = 'x'; printField(field); } } private boolean isEmpty(char[][] field) { for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2; j++) if (field[i][j] != '.') return false; return true; } private Pair selectLast(char[][] field) { for (int x0 = 0; x0 <= 2; x0++) { for (int y0 = 0; y0 <= 2; y0++) { for (int x1 = 0; x1 <= 2; x1++) { for (int y1 = 0; y1 <= 2; y1++) { int dx = x1 - x0; int dy = y1 - y0; if (Math.abs(dx) + Math.abs(dy) == 0) continue; if (Math.abs(dx) > 1 || Math.abs(dy) > 1) continue; if (field[x0][y0] != 'x') continue; if (field[x1][y1] != 'x') continue; int x2 = x1 + dx, y2 = y1 + dy; if (x2 >= 0 && x2 <= 2 && y2 >= 0 && y2 <= 2 && field[x2][y2] == '.') { return new Pair(x2, y2); } } } } } throw new AssertionError(); } private Pair selectSupport(char[][] field) { for (int x = 0; x <= 2; x++) { for (int y = 0; y <= 2; y++) { if ((x + y) % 2 == 1 && field[x][y] == '.') { field[x][y] = 'x'; int ways = calcWays(field); if (ways >= 2) { return new Pair(x, y); } field[x][y] = '.'; } } } throw new AssertionError(); } private int calcWays(char[][] field) { boolean[][] used = new boolean[3][3]; for (int x0 = 0; x0 <= 2; x0++) { for (int y0 = 0; y0 <= 2; y0++) { for (int x1 = 0; x1 <= 2; x1++) { for (int y1 = 0; y1 <= 2; y1++) { int dx = x1 - x0; int dy = y1 - y0; if (Math.abs(dx) + Math.abs(dy) == 0) continue; if (Math.abs(dx) > 1 || Math.abs(dy) > 1) continue; if (field[x0][y0] != 'x') continue; if (field[x1][y1] != 'x') continue; int x2 = x1 + dx, y2 = y1 + dy; if (x2 >= 0 && x2 <= 2 && y2 >= 0 && y2 <= 2 && field[x2][y2] == '.') { used[x2][y2] = true; } } } } } int res = 0; for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2; j++) if (used[i][j]) ++res; return res; } private Pair selectCorner(char[][] field) { int[] xs = { 0, 2 }, ys = { 0, 2 }; for (int x : xs) for (int y : ys) { if (field[x][y] == '.') return new Pair(x, y); } throw new AssertionError(); } private void printField(char[][] field) { for (int i = 0; i < 3; i++) out.println(new String(field[i])); out.flush(); } private char[][] readField() throws IOException { char[][] result = new char[3][]; for (int i = 0; i < 3; i++) result[i] = nextToken().toCharArray(); return result; } private boolean isOver(char[][] field) { for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2; j++) if (field[i][j] != 'x') return false; return true; } public static void main(String[] args) { new TicTac().run(); } public void run() { final String className = this.getClass().getName().toLowerCase(); try { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); rnd = new Random(); solve(); out.close(); } catch (IOException e) { e.printStackTrace(); System.exit(1); } } private String nextToken() throws IOException { while (st == null || !st.hasMoreTokens()) { String line = in.readLine(); if (line == null) return null; st = new StringTokenizer(line); } return st.nextToken(); } private int nextInt() throws IOException { return Integer.parseInt(nextToken()); } private long nextLong() throws IOException { return Long.parseLong(nextToken()); } private double nextDouble() throws IOException { return Double.parseDouble(nextToken()); } }
Encontrar Diferença