Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
Untitled diff
생성일
11년 전
비교 결과 만료 없음
초기화
내보내기
공유
설명
8 삭제
행
총
삭제
글자
총
삭제
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
215 행
복사
0 추가
행
총
추가
글자
총
추가
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
210 행
복사
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 {
복사
복사됨
복사
복사됨
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());
}
}
}
}
저장된 비교 결과
원본
파일 열기
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()); } }
수정본
파일 열기
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()); } }
비교하기