Submission #3376350

Source Code Expand

Copy
```#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

//n×n行列の行列式を求める
ll determinant(vector<vector<ll>> M) {
const ll n = M.size();
ll result = 1;
for (ll i = 0; i < n; i++) {
if (M[i][i] == 0) {
//対角成分が0だった場合はその列の値が0でない行と交換する
for (ll ni = i + 1; ni < n; ni++) {
if (M[ni][i] != 0) {
swap(M[i], M[ni]);
//result = -result;
break;
}
}
}

if (M[i][i] == 0) {
return 0;
}

for (ll ni = i + 1; ni < n; ni++) {
//ni行のi列目を全て0にする
//ll r = M[ni][i] / M[i][i];

for (ll j = i + 1; j < n; j++) {
//M[ni][j] -= r * M[i][j];
M[ni][j] ^= M[ni][i] * M[i][j];
}
}

//行列式は対角成分の積
result *= M[i][i];
}
return result;
}

int main() {
ll N;
cin >> N;
vector<vector<ll>> M(N, vector<ll>(N));
for (ll i = 0; i < N; i++) {
string S;
cin >> S;
for (ll j = 0; j < N; j++) {
M[i][j] = S[j] - '0';
}
}

cout << (determinant(M) % 2 == 0 ? "Even" : "Odd") << endl;
}```

#### Submission Info

Submission Time 2018-10-10 13:24:49+0900 C - 鯛焼き tokumini C++14 (GCC 5.4.1) 100 1387 Byte AC 6 ms 896 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All 100 / 100 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
01.txt 1 ms 256 KB
02.txt 1 ms 256 KB
03.txt 1 ms 256 KB
04.txt 1 ms 256 KB
05.txt 1 ms 256 KB
06.txt 1 ms 256 KB
07.txt 1 ms 256 KB
08.txt 1 ms 256 KB
09.txt 1 ms 256 KB
10.txt 1 ms 256 KB
11.txt 1 ms 256 KB
12.txt 1 ms 256 KB
13.txt 1 ms 256 KB
14.txt 1 ms 256 KB
15.txt 1 ms 256 KB
16.txt 1 ms 256 KB
17.txt 1 ms 256 KB
18.txt 1 ms 256 KB
19.txt 1 ms 256 KB
20.txt 1 ms 256 KB
21.txt 6 ms 896 KB
22.txt 5 ms 896 KB
23.txt 5 ms 896 KB
24.txt 6 ms 896 KB
25.txt 5 ms 896 KB
26.txt 5 ms 896 KB
27.txt 5 ms 896 KB
28.txt 5 ms 896 KB
29.txt 5 ms 896 KB
30.txt 5 ms 896 KB
31.txt 5 ms 896 KB
32.txt 5 ms 896 KB
33.txt 5 ms 896 KB
34.txt 5 ms 896 KB
35.txt 3 ms 896 KB
36.txt 5 ms 896 KB
37.txt 3 ms 896 KB
38.txt 5 ms 896 KB
39.txt 5 ms 896 KB
40.txt 3 ms 896 KB
41.txt 5 ms 896 KB
42.txt 5 ms 896 KB
43.txt 5 ms 896 KB
44.txt 5 ms 896 KB
45.txt 6 ms 896 KB
46.txt 3 ms 896 KB
47.txt 1 ms 256 KB
48.txt 1 ms 256 KB
49.txt 1 ms 256 KB
50.txt 1 ms 256 KB
51.txt 1 ms 256 KB
52.txt 1 ms 256 KB
53.txt 1 ms 256 KB
54.txt 1 ms 256 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
sample_04.txt 1 ms 256 KB