提出 #38028178


ソースコード 拡げる

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int h, w, q, r1 = 1, r2 = 2, c1 = 1, c2 = 2;
	
	cin >> h >> w;
	vector<vector<char>> a(h + 5, vector<char>(w + 5)); 
	
	for (int i = 1; i <= h; i++) 
		for (int j = 1; j <= w; j++) 
			cin >> a[i][j];
			
	auto update = [](int &p, const int &x, const int &n) {
		if (p <= x) 
			p = x - p + 1;
		else
			p = n - p + 1 + x;
	};
	
	cin >> q;
	for (int x, y; q; q--) {
		cin >> x >> y;
		update(r1, x, h);
		update(r2, x, h);
		update(c1, y, w);
		update(c2, y, w);
	}
	
	vector<int> r(h + 5), c(w + 5);
	for (int i = r1, step = abs(r2 - r1) == 1 ? r2 - r1 : r1 < r2 ? -1 : 1, cnt = 1; cnt <= h; cnt++, i = (i + step - 1 + h) % h + 1) 
		r[i] = cnt;
	for (int j = c1, step = abs(c2 - c1) == 1 ? c2 - c1 : c1 < c2 ? -1 : 1, cnt = 1; cnt <= w; cnt++, j = (j + step - 1 + w) % w + 1)
		c[j] = cnt;
		
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) 
			cout << a[r[i]][c[j]];
		cout << '\n';
	} 
}

提出情報

提出日時
問題 B - Grid Rotations
ユーザ x_x_
言語 C++ (GCC 9.2.1)
得点 500
コード長 1111 Byte
結果 AC
実行時間 71 ms
メモリ 17912 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 3
AC × 32
セット名 テストケース
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 03_rand_01.txt, 03_rand_02.txt, 03_rand_03.txt, 03_rand_04.txt, 03_rand_05.txt, 04_square_01.txt, 04_square_02.txt, 04_square_03.txt, 04_square_04.txt, 04_square_05.txt, 05_max_H_01.txt, 05_max_H_02.txt, 05_max_H_03.txt, 05_max_H_04.txt, 05_max_H_05.txt, 06_max_W_01.txt, 06_max_W_02.txt, 06_max_W_03.txt, 06_max_W_04.txt, 06_max_W_05.txt
ケース名 結果 実行時間 メモリ
01_sample_01.txt AC 8 ms 3552 KiB
01_sample_02.txt AC 2 ms 3472 KiB
01_sample_03.txt AC 2 ms 3556 KiB
02_small_01.txt AC 3 ms 3476 KiB
02_small_02.txt AC 2 ms 3560 KiB
02_small_03.txt AC 2 ms 3552 KiB
02_small_04.txt AC 2 ms 3512 KiB
02_small_05.txt AC 2 ms 3564 KiB
02_small_06.txt AC 3 ms 3564 KiB
02_small_07.txt AC 2 ms 3452 KiB
02_small_08.txt AC 2 ms 3444 KiB
02_small_09.txt AC 2 ms 3564 KiB
03_rand_01.txt AC 42 ms 3580 KiB
03_rand_02.txt AC 43 ms 3948 KiB
03_rand_03.txt AC 33 ms 3632 KiB
03_rand_04.txt AC 43 ms 3708 KiB
03_rand_05.txt AC 37 ms 3700 KiB
04_square_01.txt AC 47 ms 3596 KiB
04_square_02.txt AC 48 ms 3672 KiB
04_square_03.txt AC 44 ms 3704 KiB
04_square_04.txt AC 46 ms 3712 KiB
04_square_05.txt AC 47 ms 3628 KiB
05_max_H_01.txt AC 71 ms 17912 KiB
05_max_H_02.txt AC 70 ms 17816 KiB
05_max_H_03.txt AC 70 ms 17872 KiB
05_max_H_04.txt AC 68 ms 17860 KiB
05_max_H_05.txt AC 70 ms 17828 KiB
06_max_W_01.txt AC 49 ms 5604 KiB
06_max_W_02.txt AC 49 ms 5600 KiB
06_max_W_03.txt AC 54 ms 5656 KiB
06_max_W_04.txt AC 50 ms 5768 KiB
06_max_W_05.txt AC 51 ms 5652 KiB