結果

問題 No.2824 Lights Up! (Grid Edition)
ユーザー achapiachapi
提出日時 2024-07-25 08:41:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,207 bytes
コンパイル時間 2,330 ms
コンパイル使用メモリ 209,444 KB
実行使用メモリ 15,560 KB
最終ジャッジ日時 2024-07-26 20:35:06
合計ジャッジ時間 9,873 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 77 ms
14,840 KB
testcase_05 AC 77 ms
14,328 KB
testcase_06 AC 55 ms
9,816 KB
testcase_07 AC 723 ms
9,944 KB
testcase_08 AC 78 ms
13,928 KB
testcase_09 AC 78 ms
14,708 KB
testcase_10 AC 54 ms
9,816 KB
testcase_11 AC 718 ms
11,224 KB
testcase_12 AC 77 ms
13,860 KB
testcase_13 WA -
testcase_14 AC 75 ms
14,776 KB
testcase_15 WA -
testcase_16 AC 76 ms
14,600 KB
testcase_17 WA -
testcase_18 AC 76 ms
13,992 KB
testcase_19 WA -
testcase_20 AC 27 ms
8,188 KB
testcase_21 AC 54 ms
13,408 KB
testcase_22 AC 4 ms
6,944 KB
testcase_23 AC 581 ms
8,528 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 WA -
testcase_26 AC 30 ms
8,864 KB
testcase_27 WA -
testcase_28 AC 3 ms
6,940 KB
testcase_29 WA -
testcase_30 AC 4 ms
6,940 KB
testcase_31 WA -
testcase_32 AC 9 ms
6,940 KB
testcase_33 AC 3 ms
6,944 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 WA -
testcase_36 AC 2 ms
6,944 KB
testcase_37 WA -
testcase_38 AC 2 ms
6,940 KB
testcase_39 AC 2 ms
6,940 KB
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 WA -
testcase_44 AC 2 ms
6,944 KB
testcase_45 AC 2 ms
6,944 KB
testcase_46 AC 2 ms
6,940 KB
testcase_47 AC 2 ms
6,940 KB
testcase_48 AC 2 ms
6,940 KB
testcase_49 AC 2 ms
6,940 KB
testcase_50 AC 2 ms
6,944 KB
testcase_51 AC 2 ms
6,940 KB
testcase_52 AC 2 ms
6,940 KB
testcase_53 AC 2 ms
6,940 KB
testcase_54 AC 1 ms
6,940 KB
testcase_55 AC 2 ms
6,944 KB
testcase_56 AC 2 ms
6,944 KB
testcase_57 AC 2 ms
6,944 KB
testcase_58 AC 2 ms
6,944 KB
testcase_59 AC 2 ms
6,940 KB
testcase_60 AC 2 ms
6,944 KB
testcase_61 WA -
testcase_62 AC 2 ms
6,940 KB
testcase_63 WA -
testcase_64 AC 2 ms
6,940 KB
testcase_65 AC 2 ms
6,940 KB
testcase_66 AC 2 ms
6,940 KB
testcase_67 AC 2 ms
6,940 KB
testcase_68 AC 2 ms
6,940 KB
testcase_69 AC 2 ms
6,944 KB
testcase_70 AC 2 ms
6,940 KB
testcase_71 AC 2 ms
6,940 KB
testcase_72 AC 2 ms
6,940 KB
testcase_73 AC 2 ms
6,940 KB
testcase_74 AC 1 ms
6,940 KB
testcase_75 AC 2 ms
6,944 KB
testcase_76 AC 2 ms
6,940 KB
testcase_77 AC 2 ms
6,940 KB
testcase_78 AC 2 ms
6,944 KB
testcase_79 AC 2 ms
6,940 KB
testcase_80 AC 2 ms
6,940 KB
testcase_81 AC 2 ms
6,940 KB
testcase_82 AC 2 ms
6,944 KB
testcase_83 AC 2 ms
6,940 KB
testcase_84 AC 2 ms
6,940 KB
testcase_85 AC 2 ms
6,940 KB
testcase_86 AC 2 ms
6,944 KB
testcase_87 AC 2 ms
6,944 KB
testcase_88 AC 2 ms
6,940 KB
testcase_89 AC 2 ms
6,940 KB
testcase_90 AC 2 ms
6,940 KB
testcase_91 AC 2 ms
6,940 KB
testcase_92 AC 2 ms
6,940 KB
testcase_93 AC 1 ms
6,940 KB
testcase_94 AC 2 ms
6,940 KB
testcase_95 AC 2 ms
6,944 KB
testcase_96 AC 2 ms
6,944 KB
testcase_97 AC 2 ms
6,940 KB
testcase_98 AC 2 ms
6,944 KB
testcase_99 AC 2 ms
6,944 KB
testcase_100 AC 2 ms
6,944 KB
testcase_101 AC 1 ms
6,940 KB
testcase_102 AC 2 ms
6,944 KB
testcase_103 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; i++){
		cin >> S[i];
	}
	auto op = [&](int r, int c){
		S[r][c] ^= '.' ^ '#';
		S[(N + r - 1) % N][c] ^= '.' ^ '#';
		S[r][(N + c - 1) % N] ^= '.' ^ '#';
		S[(N + r - 1) % N][(N + c - 1) % N] ^= '.' ^ '#';
	};
	vector<pair<int, int>> ans;
	for (int i = 1; i < N; i++){
		for (int j = 1; j < N; j++){
			if (S[i - 1][j - 1] == '#'){
				ans.push_back(make_pair(i, j));
				op(i, j);
				op(i, 0);
				op(0, j);
			}
		}
	}
	for (int i = 1; i < N; i += 2){
		if (S[i][0] == '#'){
			for (int j = 0; j < N; j++){
				ans.push_back(make_pair(i, j));
				op(i, j);
				op(i, 0);
				op(0, j);
			}
		}
		if (S[0][i] == '#'){
			for (int j = 0; j < N; j++){
				ans.push_back(make_pair(j, i));
				op(j, i);
				op(j, 0);
				op(0, i);
			}
		}
	}
	if (S[0][0] == '#'){
		ans.push_back(make_pair(0, 0));
		op(0, 0);
	}
	bool ok = true;
	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			if (S[i][j] == '#'){
				ok = false;
			}
		}
	}
	if (ok){
		cout << ans.size() << endl;
		for (auto [R, C] : ans){
			cout << R << ' ' << C << endl;
		}
	} else {
		cout << -1 << endl;
	}
}
0