結果
問題 |
No.1210 XOR Grid
|
ユーザー |
|
提出日時 | 2020-09-06 21:31:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 415 ms / 2,000 ms |
コード長 | 1,134 bytes |
コンパイル時間 | 1,675 ms |
コンパイル使用メモリ | 107,484 KB |
最終ジャッジ日時 | 2025-01-14 08:02:18 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 57 |
ソースコード
#include <cmath> #include <vector> #include <iostream> #include <algorithm> #include <set> #include <iomanip> #include <numeric> #include <queue> #include <string> #include <map> #include <fstream> #include <cassert> #include <stack> constexpr long long int MOD = 1000000007; long long int power(long long int base, long long int exp) { long long int result{ 1 }; while (exp > 0) { if (exp & 1) { result = (result * base) % MOD; --exp; } else { base = (base * base) % MOD; exp >>= 1; } } return result; } int main() { int n, m, x; std::cin >> n >> m >> x; std::vector<long long int> row(n), column(m); for (auto& r : row) std::cin >> r; for (auto& c : column) std::cin >> c; const auto row_xor = std::accumulate(row.begin(), row.end(), 0LL, [](const long long int acc, const long long int r) {return acc ^ r; }); const auto column_xor = std::accumulate(column.begin(), column.end(), 0LL, [](const long long int acc, const long long int l) {return acc ^ l; }); if (row_xor != column_xor) { std::cout << 0 << '\n'; return 0; } std::cout << power((1LL << x) % MOD, (n - 1LL) * (m - 1LL)) << '\n'; }