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.Q16927; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int r = sc.nextInt(); int[][] a = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = sc.nextInt(); } } ArrayList<ArrayList<Integer>> groups = new ArrayList<>(); int groupn = Math.min(n, m) / 2; for (int k = 0; k < groupn; k++) { ArrayList<Integer> group = new ArrayList<>(); for (int j = k; j < m - k; j++) { group.add(a[k][j]); } for (int i = k + 1; i < n - k - 1; i++) { group.add(a[i][m - k - 1]); } for (int j = m - k - 1; j > k; j--) { group.add(a[n - k - 1][j]); } for (int i = n - k - 1; i > k; i--) { group.add(a[i][k]); } groups.add(group); } for (int k = 0; k < groupn; k++) { ArrayList<Integer> group = groups.get(k); int len = group.size(); int index = r % len; for (int j = k; j < m - k; j++, index = (index + 1) % len) { a[k][j] = group.get(index); } for (int i = k + 1; i < n - k - 1; i++, index = (index + 1) % len) { a[i][m - k - 1] = group.get(index); } for (int j = m - k - 1; j > k; j--, index = (index + 1) % len) { a[n - k - 1][j] = group.get(index); } for (int i = n - k - 1; i > k; i--, index = (index + 1) % len) { a[i][k] = group.get(index); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { System.out.print(a[i][j] + " "); } System.out.println(); } } }
The text was updated successfully, but these errors were encountered:
3a747dc
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
The text was updated successfully, but these errors were encountered: