We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
package main.java.com.poogle.BOJ.Q15662; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[][] a = new char[n][8]; for (int i = 0; i < n; i++) { a[i] = sc.next().toCharArray(); } int k = sc.nextInt(); while (k-- > 0) { int no = sc.nextInt() - 1; int dir = sc.nextInt(); //각 톱니가 어떤 방향으로 회전하는지 int[] d = new int[n]; d[no] = dir; //왼쪽 for (int i = no - 1; i >= 0; i--) { if (a[i][2] != a[i + 1][6]) { d[i] = -d[i + 1]; } else { break; } } //오른쪽 for (int i = no + 1; i < n; i++) { if (a[i - 1][2] != a[i][6]) { d[i] = -d[i - 1]; } else { break; } } for (int i = 0; i < n; i++) { if (d[i] == 0) continue; if (d[i] == 1) { //시계방향 char temp = a[i][7]; for (int j = 7; j >= 1; j--) { a[i][j] = a[i][j - 1]; } a[i][0] = temp; } else if (d[i] == -1) { //반시계방향 char temp = a[i][0]; for (int j = 0; j < 7; j++) { a[i][j] = a[i][j + 1]; } a[i][7] = temp; } } } int ans = 0; for (int i = 0; i < n; i++) { if (a[i][0] == '1') { ans += 1; } } System.out.println(ans); } }
The text was updated successfully, but these errors were encountered:
7cddf7d
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
The text was updated successfully, but these errors were encountered: