Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BOJ_1244_당현아 #111

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

Merged
hadevyi merged 2 commits into main from eona1301_thu_algo
Sep 26, 2021
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
44 changes: 44 additions & 0 deletions Baekjoon/1244/Main_당현아.java
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import java.util.Scanner;

public class Main {
static int N, TOTAL;
static int[] switchArray;

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
N = sc.nextInt();
switchArray = new int[N];

for (int i = 0; i < N; i++)
switchArray[i] = sc.nextInt();

TOTAL = sc.nextInt();
for (int tryCnt = 0; tryCnt < TOTAL; tryCnt++) {
int gender = sc.nextInt();
int number = sc.nextInt();

if (gender == 1) // 남자일 경우 - 배수
for (int i = (number - 1); i < N; i += number)
switchArray[i] = (switchArray[i] == 0) ? 1 : 0;
else { // 여자일 경우 - 대칭확인
switchArray[number - 1] = (switchArray[number - 1] == 0) ? 1 : 0;
for (int i = 1; (number-1) - i >= 0 && i + (number-1) < N; i++) {
if (switchArray[(number-1) - i] == switchArray[(number-1) + i]) {
switchArray[(number-1) - i] = (switchArray[(number-1) - i] == 0) ? 1 : 0;
switchArray[(number-1) + i] = (switchArray[(number-1) + i] == 0) ? 1 : 0;
}
else break;
}
}

}

for (int i = 0; i < switchArray.length; i++) {
System.out.print(switchArray[i] + " ");
if ((i + 1) % 20 == 0)
System.out.println();
}
sc.close();
}

}
2 changes: 1 addition & 1 deletion README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
</tr>
<tr>
<td align="center"><a href="https://github.com/SSAFY5-Algorithms-Kid/Algorithms-Solved/tree/main/Baekjoon/1244">BOJ 1244</a></td>
<td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td>
<td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td>
<td align="center">✅</td><td align="center"></td><td align="center"></td><td align="center"></td>
</tr>
<tr>
Expand Down

AltStyle によって変換されたページ (->オリジナル) /