import java.util.Scanner;
/**
- @author kyp
- @time 2019/7/17
- @description 图像旋转
*/
public class _20150301 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
if (n>1000||m>1000){
return;
}
int[][] a = new int[n][m];
for (int i=0;i<n;i++){
for (int j=0;j<m;j++){
a[i][j]=scanner.nextInt();
}
}
for (int i=0;i<m;i++){
for (int j=0;j<n;j++){
System.out.print(a[j][m - i - 1]);
System.out.print(" ");
}
System.out.println("");
}
}
}
相同的代码有时候显示是80分有时候是90分,然后我有去网上看别人的代码,相同的逻辑,有些人是100分,计算了一下,应该不会超限才对啊,for一下才1000*1000/1024
然后去网上找答案了,说是nextInt频繁IO操作会耗时,要使用BufferedReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;
public class _20131201 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String head = br.readLine();
String[] temp = head.split(" ");
int n = Integer.parseInt(temp[0]);
int m = Integer.parseInt(temp[1]);
int[][] a = new int[n][m];
for (int i = 0; i < n; i++) {
temp = br.readLine().split(" ");
for (int j = 0; j < m; j++) {
a[i][j] = Integer.parseInt(temp[j]);
}
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(a[j][m - 1 - i]);
System.out.print(" ");
}
System.out.println();
}
}
}
折腾了很久,本来打算一天刷完CCF全部的第一题的,这题看起来很简单,以为做得很快的,结果还是有知识的薄弱点啊