結果

問題 No.565 回転拡大
ユーザー 37zigen37zigen
提出日時 2020-03-19 18:08:42
言語 Java19
(openjdk 21)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 3,082 bytes
コンパイル時間 3,652 ms
コンパイル使用メモリ 74,204 KB
実行使用メモリ 53,692 KB
最終ジャッジ日時 2023-08-20 21:01:00
合計ジャッジ時間 7,369 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
53,692 KB
testcase_01 AC 95 ms
51,664 KB
testcase_02 AC 77 ms
50,480 KB
testcase_03 AC 38 ms
49,200 KB
testcase_04 AC 81 ms
51,652 KB
testcase_05 AC 37 ms
49,720 KB
testcase_06 AC 85 ms
51,244 KB
testcase_07 AC 79 ms
49,948 KB
testcase_08 AC 97 ms
51,684 KB
testcase_09 AC 39 ms
49,016 KB
testcase_10 AC 38 ms
49,012 KB
testcase_11 AC 45 ms
47,168 KB
testcase_12 AC 81 ms
51,584 KB
testcase_13 AC 42 ms
49,144 KB
testcase_14 AC 40 ms
49,124 KB
testcase_15 AC 64 ms
51,256 KB
testcase_16 AC 45 ms
49,292 KB
testcase_17 AC 41 ms
49,212 KB
testcase_18 AC 54 ms
50,908 KB
testcase_19 AC 99 ms
51,904 KB
testcase_20 AC 40 ms
49,208 KB
testcase_21 AC 42 ms
49,256 KB
testcase_22 AC 82 ms
51,104 KB
testcase_23 AC 37 ms
49,352 KB
testcase_24 AC 91 ms
49,856 KB
testcase_25 AC 101 ms
51,452 KB
testcase_26 AC 45 ms
49,136 KB
testcase_27 AC 82 ms
51,364 KB
testcase_28 AC 90 ms
51,588 KB
testcase_29 AC 48 ms
49,464 KB
testcase_30 AC 37 ms
47,148 KB
testcase_31 AC 37 ms
47,224 KB
testcase_32 AC 37 ms
49,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		long t = System.currentTimeMillis();
		new Main().run();
		System.err.println(System.currentTimeMillis() - t);
	}
	
	long gcd(long a,long b) {
		return a==0?b:gcd(b%a,a);
	}
	
	char[][] rotate(char[][] m){
		char[][] ret=new char[m[0].length][m.length];
		for(int i=0;i<m.length;++i)
			for(int j=0;j<m[i].length;++j)
				ret[j][ret[j].length-1-i]=m[i][j];
		return ret;
	}
	
	char[][] expand(char[][] m,int a){
		char[][] ret=new char[a*m.length][a*m[0].length];
		for(int i=0;i<m.length;++i) {
			for(int j=0;j<m[i].length;++j) {
				for(int k=0;k<a;++k) {
					for(int l=0;l<a;++l) {
						ret[a*i+k][a*j+l]=m[i][j];
					}
				}
			}
		}
		return ret;
	}

	void run() {
		Scanner sc = new Scanner();
		int R=sc.nextInt();
		int K=sc.nextInt();
		int H=sc.nextInt();
		int W=sc.nextInt();
		char[][] m=new char[H][W];
		for(int i=0;i<H;++i)m[i]=sc.next().toCharArray();
		for(int r=0;r<R/90;++r)m=rotate(m);
		m=expand(m, K);
		for(int i=0;i<m.length;++i) {
			for(int j=0;j<m[i].length;++j) {
				System.out.print(m[i][j]);
			}
			System.out.println();
		}
	}
	
	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			return (int) nextLong();
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0