結果

問題 No.565 回転拡大
ユーザー myantamyanta
提出日時 2017-09-08 22:55:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,068 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 42,368 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 21:28:22
合計ジャッジ時間 1,209 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:56:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   56 |                         scanf("%[.#]\n", &s[y][0]);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<vector>


using namespace std;


using vc=vector<char>;
using vvc=vector<vc>;


void rot(vvc&d, vvc&s, int r)
{
	int sw, sh, dw, dh;

	sw=dw=s[0].size();
	sh=dh=s.size();
	if(r==90 || r==270)
	{
		dw=sh;
		dh=sw;
	}
	d.resize(dh);
	for(auto&de:d) de.resize(dw);

	for(int sy=0;sy<sh;sy++)
	{
		for(int sx=0;sx<sw;sx++)
		{
			int dx=sx, dy=sy;
			switch(r)
			{
				case   0: dx=sx; dy=sy; break;
				case  90: dx=dw-1-sy; dy=sx; break;
				case 180: dx=dw-1-sx; dy=dh-1-sy; break;
				case 270: dx=sy; dy=dh-1-sx; break;
			}
			d[dy][dx]=s[sy][sx];
		}
	}
}


int main(void)
{
	int r, k, h, w;

	while(scanf("%d%d%d%d\n", &r, &k, &h, &w)==4)
	{
		vvc s(h), d;

		for(auto&se:s) se.resize(w+2);

		for(int y=0;y<h;y++)
		{
			scanf("%[.#]\n", &s[y][0]);
			s[y].resize(w);
		}
		rot(d, s, r);
		int dw=d[0].size();
		int dh=d.size();
		for(int y=0;y<dh;y++)
		{
			for(int i=0;i<k;i++)
			{
				for(int x=0;x<dw;x++)
				{
					for(int j=0;j<k;j++)
					{
						printf("%c", d[y][x]);
					}
				}
				printf("\n");
			}
		}
	}
	return 0;
}
0