-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from Kut-PS-Study/Dltmd202
Dltmd202
- Loading branch information
Showing
6 changed files
with
242 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.StringTokenizer; | ||
|
||
public class Main { | ||
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
static StringBuilder sb = new StringBuilder(); | ||
|
||
public static void main(String[] args) throws IOException { | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
|
||
int n = Integer.parseInt(st.nextToken()); | ||
int m = Integer.parseInt(st.nextToken()); | ||
char[][] map = new char[n][m]; | ||
char[] checker = {'W', 'B'}; | ||
|
||
for (int i = 0; i < n; i++) { | ||
map[i] = br.readLine().toCharArray(); | ||
} | ||
|
||
int res = Integer.MAX_VALUE; | ||
for (int i = 0; i <= n - 8; i++) { | ||
for (int j = 0; j <= m - 8; j++) { | ||
res = Math.min(res, check(n, m, map, checker, 0, i, j)); | ||
res = Math.min(res, check(n, m, map, checker, 1, i, j)); | ||
} | ||
} | ||
System.out.println(res); | ||
} | ||
|
||
private static int check(int n, int m, char[][] map, char[] checker, int grad, int sy, int sx) { | ||
int modified = 0; | ||
int turn = grad; | ||
for (int i = sy; i < sy + 8; i++) { | ||
for (int j = sx; j < sx + 8; j++) { | ||
if (checker[turn % 2] != map[i][j]) { | ||
modified++; | ||
} | ||
turn++; | ||
} | ||
turn++; | ||
} | ||
return modified; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.StringTokenizer; | ||
|
||
public class Main { | ||
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
static class Coordinate{ | ||
int x; | ||
int y; | ||
|
||
public Coordinate(int x, int y) { | ||
this.y = y; | ||
this.x = x; | ||
} | ||
|
||
private int minDifference(Coordinate c){ | ||
return Math.min( | ||
Math.abs(this.x - c.x), | ||
Math.abs(this.y - c.y) | ||
); | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
Coordinate hansu = new Coordinate( | ||
Integer.parseInt(st.nextToken()), | ||
Integer.parseInt(st.nextToken()) | ||
); | ||
|
||
Coordinate lowerLeft = new Coordinate(0 ,0); | ||
|
||
Coordinate upperRight = new Coordinate( | ||
Integer.parseInt(st.nextToken()), | ||
Integer.parseInt(st.nextToken()) | ||
); | ||
|
||
int min = Integer.MAX_VALUE; | ||
|
||
min = Math.min(min, hansu.minDifference(lowerLeft)); | ||
min = Math.min(min, hansu.minDifference(upperRight)); | ||
|
||
System.out.println(min); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.Arrays; | ||
import java.util.Comparator; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class Main { | ||
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
static StringBuilder sb = new StringBuilder(); | ||
|
||
public static void main(String[] args) throws IOException { | ||
int n = Integer.parseInt(br.readLine()); | ||
String[] strs = new String[n]; | ||
Set<String> visited = new HashSet<>(); | ||
|
||
for (int i = 0; i < n; i++) { | ||
strs[i] = br.readLine(); | ||
} | ||
|
||
Arrays.sort(strs, | ||
new Comparator<String>() { | ||
@Override | ||
public int compare(String o1, String o2) { | ||
if(o1.length() == o2.length()) | ||
return o1.compareTo(o2); | ||
else { | ||
return o1.length() - o2.length(); | ||
} | ||
} | ||
}); | ||
|
||
System.out.println( | ||
Arrays.stream(strs) | ||
.filter(s -> { | ||
if(!visited.contains(s)){ | ||
visited.add(s); | ||
return true; | ||
} | ||
return false; | ||
}) | ||
.map(String::valueOf) | ||
.collect(Collectors.joining("\n")) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
public class Main { | ||
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
static StringBuilder sb = new StringBuilder(); | ||
|
||
public static void main(String[] args) throws IOException { | ||
while (true){ | ||
int n = Integer.parseInt(br.readLine()); | ||
if(n == 0) break; | ||
char[] ary = String.valueOf(n).toCharArray(); | ||
sb.append(getAnswer(ary)).append("\n"); | ||
} | ||
System.out.println(sb.toString()); | ||
} | ||
|
||
private static String getAnswer(char[] ary) { | ||
int left = 0, right = ary.length - 1; | ||
|
||
while (left < right){ | ||
if(ary[left++] != ary[right--]) return "no"; | ||
} | ||
return "yes"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
public class Main { | ||
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
static StringBuilder sb = new StringBuilder(); | ||
|
||
public static void main(String[] args) throws IOException { | ||
int turn = Integer.parseInt(br.readLine()); | ||
long n = 666; | ||
|
||
int cnt = 0; | ||
while (true){ | ||
char[] numArray = String.valueOf(n).toCharArray(); | ||
if(isValid(numArray)) cnt++; | ||
if(cnt == turn) break; | ||
n++; | ||
} | ||
System.out.println(n); | ||
} | ||
|
||
private static boolean isValid(char[] numArray) { | ||
for (int i = 0; i <= numArray.length - 3; i++) { | ||
if(numArray[i] == '6' && numArray[i + 1] == '6' && numArray[i + 2] == '6'){ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |