結果

問題 No.460 裏表ちわーわ
ユーザー hirokazu1020hirokazu1020
提出日時 2016-12-11 00:41:26
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,693 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 103,204 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-19 10:53:37
合計ジャッジ時間 2,912 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n, m;
int b[8][8];

vector<int> GaussJordanMod2(vector<vector<int> > a) {
	int n = a.size();
	for (int i = 0; i<n; i++) {
		for (int j = i; j<n; j++) {
			if (a[j][i]) {
				a[i].swap(a[j]);
				break;
			}
		}
		vector<int> invalid(n);
		invalid.push_back(1);
		if (a[i] == invalid)return vector<int>();

		for (int j = 0; j<n; j++) {
			if (i == j || a[j][i] == 0)continue;
			for (int k = i; k<n + 1; k++) {
				a[j][k] = (a[j][k] - a[i][k] + 2) % 2;
			}
		}
	}
	vector<int> res(n);
	for (int i = 0; i<n; i++)res[i] = a[i][n];
	return res;
}




int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m;
	rep(i,n) {
		rep(j, m) {
			cin >> b[i][j];
		}
	}
	int dy[] = { 0,-1,0,1,0 ,1,1,-1,-1};
	int dx[] = { 0,0,-1,0,1 ,1,-1,1,-1};
	vector<vector<int>> v;
	rep(i, n) {
		rep(j, m) {
			v.emplace_back(n*m + 1);
			rep(k,9) {
				int y = i + dy[k];
				int x = j + dx[k];
				if (0<=x&&x<m && 0<=y&&y<n) {
					v.back()[y*m + x] = 1;
				}
			}
			v.back()[n*m] = b[i][j];
		}
	}
	auto res = GaussJordanMod2(v);
	if (res.empty())cout << "Impossible" << endl;
	else cout << count(all(res), 1) << endl;

	return 0;
}
0