Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat:Add solution of #118 #125

Merged
merged 1 commit into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions src/BaekJoon/sa11k/1018/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import java.io.*;
import java.util.*;

class Main{
static boolean[][] chess;
static int result = Integer.MAX_VALUE;
static int N, M;

public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine(), " ");

N = Integer.parseInt(st.nextToken());
M = Integer.parseInt(st.nextToken());

chess = new boolean[N][M]; // W : true, B : false

for(int i = 0; i<N; i++){
String s = br.readLine();
for(int j = 0; j<M; j++){
if(s.charAt(j) == 'W'){
chess[i][j] = true;
}else{
chess[i][j] = false;
}
}
}

checkchess();

System.out.println(result);

br.close();
}

static void checkchess(){
for(int i = 0; i<=N-8; i++){
for(int j = 0; j<=M-8; j++){
W_comparechess(i, j);
B_comparechess(i, j);
}
}
}

static void W_comparechess(int r, int c){
boolean condition = true;
boolean first = true;
int count = 0;

if(first != chess[r][c]) count++;

for(int i = r; i<r+8; i++){
if(i>r && first == chess[i][c]){
count++;
first = !chess[i][c];
condition = !chess[i][c];
}else if(i>r && first != chess[i][c]) {
first = chess[i][c];
condition = chess[i][c];
}
for(int j = c+1; j<c+8; j++){
if(!condition == chess[i][j]){
condition = chess[i][j];
}else{
count++;
condition = !chess[i][j];
}
}
}

if(count<result) result = count;
}

static void B_comparechess(int r, int c){
boolean condition = false;
boolean first = false;
int count = 0;

if(first != chess[r][c]) count++;

for(int i = r; i<r+8; i++){
if(i>r && first == chess[i][c]){
count++;
first = !chess[i][c];
condition = !chess[i][c];
}else if(i>r && first != chess[i][c]) {
first = chess[i][c];
condition = chess[i][c];
}
for(int j = c+1; j<c+8; j++){
if(!condition == chess[i][j]){
condition = chess[i][j];
}else{
count++;
condition = !chess[i][j];
}
}
}

if(count<result) result = count;
}

}
30 changes: 30 additions & 0 deletions src/BaekJoon/sa11k/1085/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import java.io.*;
import java.util.*;

class Main{
static int x, y, w, h;
static int result = Integer.MAX_VALUE;

public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine(), " ");

x = Integer.parseInt(st.nextToken());
y = Integer.parseInt(st.nextToken());
w = Integer.parseInt(st.nextToken());
h = Integer.parseInt(st.nextToken());

escape(x, w-x, h-y, y);

System.out.println(result);

br.close();
}

static void escape(int left, int right, int up, int down){
if(result>left) result = left;
if(result>right) result = right;
if(result>up) result = up;
if(result>down) result = down;
}
}
35 changes: 35 additions & 0 deletions src/BaekJoon/sa11k/1181/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import java.io.*;
import java.util.*;

class Main{
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
String[] word = new String[N];

for(int i = 0; i<N; i++){
word[i] = br.readLine();
}

Arrays.sort(word, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
if(s1.length() == s2.length()){
return s1.compareTo(s2);
}else{
return s1.length()-s2.length();
}
}
});

System.out.println(word[0]);

for(int i = 1; i<N; i++){
if(!(word[i].equals(word[i-1]))){
System.out.println(word[i]);
}
}

br.close();
}
}
27 changes: 27 additions & 0 deletions src/BaekJoon/sa11k/1259/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import java.io.*;
import java.util.*;

class Main{
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

while(true){
String num = br.readLine();
if(Integer.parseInt(num) == 0) break;

String reverseNum = "";

for(int i = num.length()-1; i>=0; i--){
reverseNum += num.charAt(i);
}

if(num.equals(reverseNum)){
System.out.println("yes");
}else{
System.out.println("no");
}
}

br.close();
}
}
24 changes: 24 additions & 0 deletions src/BaekJoon/sa11k/1436/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.io.*;
import java.util.*;

class Main{
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int check = Integer.parseInt(br.readLine());
int count = 0;
int i = 666;

while(count != check){
String num = i+"";
if(num.contains("666")){
count++;
}
i++;
}

System.out.println(i-1);


br.close();
}
}