Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <ctime>
- #include <cstdlib>
- #include <algorithm>
- #include <iostream>
- #include <chrono>
- #include <vector>
- using namespace std;
- using namespace chrono;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- const int n = 1000;
- //int d[n][n];
- unsigned calc(int start) {
- unsigned cur = start;
- vvi d(n, vi(n));
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n; j++) {
- d[i][j] = cur;
- cur = cur * 54328568 + 7384;
- }
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n; j++)
- for (int k = 0; k < n; k++)
- d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
- unsigned res = 0;
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n; j++) {
- res += d[i][j];
- }
- return res;
- }
- int main() {
- auto start = steady_clock::now();
- unsigned sum = 0;
- #pragma omp parallel for
- // #pragma omp parallel for num_threads(1)
- for (int i = 0; i < 4; i++)
- sum += calc(i);
- printf("%d\n", sum);
- printf("%d\n", clock());
- cout << duration_cast<microseconds>(steady_clock::now() - start).count() << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment