#include <bits/stdc++.h>
#define idx(i, j) ((i) * n + (j))
double BB[1024 * 1024];
void matrix_multiply(int n, const double *A, const double *B, double *C) {
memcpy(BB, B, sizeof(double) << 20);
for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) {
std::swap(BB[idx(i, j)], BB[idx(j, i)]);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
double sum0 = 0, sum1 = 0, sum2 = 0, sum3 = 0;
for (int k = 0; k < n; k += 4) {
sum0 += A[idx(i, k)] * BB[idx(j, k)];
sum1 += A[idx(i, k + 1)] * BB[idx(j, k + 1)];
sum2 += A[idx(i, k + 2)] * BB[idx(j, k + 2)];
sum3 += A[idx(i, k + 3)] * BB[idx(j, k + 3)];
}
C[idx(i, j)] = sum0 + sum1 + sum2 + sum3;
}
}
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 580.681 ms | 16 MB + 32 KB | Accepted | Score: 100 | 显示更多 |