結果
| 問題 |
No.2442 線形写像
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-25 21:35:14 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,622 bytes |
| コンパイル時間 | 4,503 ms |
| コンパイル使用メモリ | 206,656 KB |
| 実行使用メモリ | 13,644 KB |
| 最終ジャッジ日時 | 2024-12-24 08:03:01 |
| 合計ジャッジ時間 | 14,763 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 1 RE * 2 TLE * 3 |
ソースコード
import std;
void main () {
int N = readln.chomp.to!int;
long[] A = new long[](2^^N);
foreach (i; 0..2^^N) {
A[i] = readln.chomp.to!long;
}
// Nが十分に小さいので、全部見ればよい
// せっかくなので、enumCombを使ってみよう
foreach (e; enumComb(2^^N, 2)) {
if ( A[(e[0]^e[1])] != (A[e[0]]^A[e[1]]) ) {
writeln("No");
return;
}
}
writeln("Yes");
}
struct enumComb {
import std.exception;
import std.format;
long N, K;
long[] idx;
bool isEmpty;
this (long N, long K) {
auto msgN = format("Line : %s, N must be greater than or equal to 0. your input = %s", __LINE__, N);
auto msgK = format("Line : %s, K must be greater than or equal to 0. your input = %s", __LINE__, K);
enforce(0 <= N, msgN);
enforce(0 <= K, msgK);
this.N = N, this.K = K;
idx = new long[](K);
// init
foreach (i; 0..K) {
idx[i] = i;
}
if (N < K) {
isEmpty = true;
}
}
bool empty() const {
return isEmpty;
}
long[] front() {
return idx;
}
void popFront() {
long index;
(){
foreach (i; 0..K) {
if (idx[$-i-1] < N-i-1) {
idx[$-i-1]++;
index = K-i-1;
return;
}
}
// there is no choice :(
isEmpty = true;
}();
foreach (i; index+1..K) {
idx[i] = idx[i-1] + 1;
}
}
}