01
specification
Convolution F_2^64
Input contains two length-2048 sequences of unsigned 64-bit integers representing elements of F_{2^64}. Print their convolution over F_{2^64}.
Field addition is bitwise xor. Field multiplication is carryless polynomial multiplication over F_2 reduced by P(x) = x^64 + x^4 + x^3 + x + 1.
Input format matches Library Checker convolution_F_2_64: N M, then the N values of a, then the M values of b. Output N+M-1 unsigned 64-bit integers separated by spaces.
minimal Rust solution
use std::io::Read;
fn main() {
let mut input = String::new();
std::io::stdin().read_to_string(&mut input).unwrap();
let mut values = input.split_ascii_whitespace();
let n: usize = values.next().unwrap().parse().unwrap();
let m: usize = values.next().unwrap().parse().unwrap();
let a: Vec<u64> = (0..n).map(|_| values.next().unwrap().parse().unwrap()).collect();
let b: Vec<u64> = (0..m).map(|_| values.next().unwrap().parse().unwrap()).collect();
let mut c = vec![0_u64; n + m - 1];
for i in 0..n {
for j in 0..m {
c[i + j] ^= gf_mul(a[i], b[j]);
}
}
for (i, value) in c.iter().enumerate() {
if i > 0 {
print!(" ");
}
print!("{value}");
}
}
fn gf_mul(a: u64, mut b: u64) -> u64 {
let mut product = 0_u128;
while b != 0 {
let shift = b.trailing_zeros();
product ^= (a as u128) << shift;
b &= b - 1;
}
gf_reduce(product)
}
fn gf_reduce(product: u128) -> u64 {
let low = product as u64;
let high = (product >> 64) as u64;
let mut reduced = low ^ high ^ (high << 1) ^ (high << 3) ^ (high << 4);
let carry = (high >> 63) ^ (high >> 61) ^ (high >> 60);
reduced ^= carry ^ (carry << 1) ^ (carry << 3) ^ (carry << 4);
reduced
}
02
scope / runtime over time
No successful records yet.
03
leaderboard
Leaderboard
· top 3
click any row to expand · open multiple to compare
Leaderboard:
,
,
Rank
User
Lang
Best · ms
Position in CDF
Delta
BEST
1.466ms
MAX RUN
1.563ms
CYCLES
6,349,121
INSTR
19,408,659
IPC
3.057
BRANCHES
2,806,536
BR MISSES
29,840
BR MISP
1.06%
L1 MISS
16,889
L2 MISS
2,699
L3 MISS
337
(max 1.563 ms)
view profile
BEST
3.501ms
MAX RUN
3.684ms
CYCLES
15,828,067
INSTR
45,366,012
IPC
2.866
BRANCHES
1,221,361
BR MISSES
17,401
BR MISP
1.42%
L1 MISS
177,391
L2 MISS
2,661
L3 MISS
193
(+2.036 ms, +138.9%, max 3.684 ms)
view profile
BEST
110.500ms
MAX RUN
116.230ms
CYCLES
532,663,351
INSTR
1,638,424,039
IPC
3.076
BRANCHES
148,225,774
BR MISSES
3,220,747
BR MISP
2.17%
L1 MISS
16,417
L2 MISS
2,994
L3 MISS
336
(+109.034 ms, +7438.8%, max 116.230 ms)
view profile
Rank
User
Lang
Best · ms
Position in CDF
Delta
BEST
1.466ms
MAX RUN
1.563ms
CYCLES
6,349,121
INSTR
19,408,659
IPC
3.057
BRANCHES
2,806,536
BR MISSES
29,840
BR MISP
1.06%
L1 MISS
16,889
L2 MISS
2,699
L3 MISS
337
(max 1.563 ms)
view profile
BEST
3.501ms
MAX RUN
3.684ms
CYCLES
15,828,067
INSTR
45,366,012
IPC
2.866
BRANCHES
1,221,361
BR MISSES
17,401
BR MISP
1.42%
L1 MISS
177,391
L2 MISS
2,661
L3 MISS
193
(+2.036 ms, +138.9%, max 3.684 ms)
view profile
BEST
110.500ms
MAX RUN
116.230ms
CYCLES
532,663,351
INSTR
1,638,424,039
IPC
3.076
BRANCHES
148,225,774
BR MISSES
3,220,747
BR MISP
2.17%
L1 MISS
16,417
L2 MISS
2,994
L3 MISS
336
(+109.034 ms, +7438.8%, max 116.230 ms)
view profile
No successful C++ submissions yet.
04
submit