Submission #1258570

#TimeUsernameProblemLanguageResultExecution timeMemory
1258570madamadam3Triple Peaks (IOI25_triples)C++20
81.10 / 100
323 ms34092 KiB
#include "triples.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using pi = pair<int, int>; #define FOR(i, a, b) for (int i = a; i < b; i++) #define ROF(i, a, b) for (int i = a; i >= b; i--) #define each(a, x) for (auto &a : x) #define all(x) (x).begin(), (x).end() #define bg(x) (x).begin() #define en(x) (x).end() #define rev(x) reverse(all(x)) #define sz(x) int((x).size()) #define srt(x) sort(all(x)) #define cnt(a, x) count(all(x), a) #define trace(x) each(a, (x)) cout << a << " " #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound ll brute(vi h) { int n = sz(h); ll ans = 0; FOR(i, 0, n) { FOR(j, i+1, n) { FOR(k, j+1, n) { int d1 = min({k-j, k-i,j-i}), d3 = max({k-j, j-i, k-i}), f1 = min({h[i], h[j], h[k]}), f3 = max({h[i], h[j], h[k]}); int d2 = (k-j) ^ (k-i) ^ (j-i) ^ d1 ^ d3, f2 = h[i] ^ h[j] ^ h[k] ^ f1 ^ f3; if (d1 == f1 && d2 == f2 && d3 == f3) ans++; } } } return ans; } struct Triple { int i, j, k; Triple() {}; Triple(int I, int J, int K) { i = min({I, J, K}); k = max({I, J, K}); j = (I ^ J ^ K) ^ i ^ k; // lol } const bool operator<(const Triple &other) const { if (i != other.i) return i < other.i; if (j != other.j) return j < other.j; return k < other.k; } }; ll count_triples(vi h) { int n = sz(h); ll ans = 0; FOR(i, 0, n) { // count number of triples where h[i] = d(i, j) or d(i, k) int H = h[i]; set<Triple> trips; // prevent double count with dupe height int j = i + H; if (j < n) { int k1 = i + h[j], k2 = j + h[j]; // 2 cases — h[j] = d(i, k) or h[j] = d(j, k) if (k1 < n && h[k1] == (k1 - j)) trips.insert(Triple(i, j, k1)); // we know d(i, j) and d(i, k) to be h[i] and h[j], so does h[k] == d(j, k) if (k2 < n && h[k2] == (k2 - i)) trips.insert(Triple(i, j, k2)); // symmetric but this time for i } int k = i + H; if (k < n) { int j1 = i + h[k], j2 = k - h[k]; // h[k] = d(i, k), h[k] = d(j, k) if ((i < j1 && j1 < k) && h[j1] == (k - j1)) trips.insert(Triple(i, j1, k)); if ((i < j2 && j2 < k) && h[j2] == (j2 - i)) trips.insert(Triple(i, j2, k)); } for (auto &el : trips) { if (h[el.j] != h[el.i] && h[el.k] != h[el.i]) ans++; } } unordered_map<int, vector<int>> pc, nc; // positive line intercepts, negative line intercepts vi inp(n), inn(n); // lookup for the intercept FOR(i, 0, n) { int c1 = h[i] - i, c2 = h[i] + i; inp[i] = c1, inn[i] = c2; pc[c1].pb(i), nc[c2].pb(i); } for (auto &cnst : pc) { // count number of triples where h[j] = d(i, j), h[k] = d(i, k), and h[i] = d(j, k) = h[k] - h[j] int i = -cnst.first; if (i < 0 || i >= n) continue; int H = h[i]; for (auto &el : cnst.second) { int j = el, k = el + H; if (k >= n) break; if (inp[k] != inp[j]) continue; ans++; } } FOR(j, 0, n) { // count number of triples where h[j] = d(i, k), h[k] = d(i, j) and h[i] = d(j, k) = h[j] - h[k] int f1 = lower_bound(all(pc[inp[j]]), j-h[j]) - bg(pc[inp[j]]); int f2 = upper_bound(all(nc[inn[j]]), j+h[j]) - bg(nc[inn[j]]); int p1 = lower_bound(all(pc[inp[j]]), j) - bg(pc[inp[j]]), p2 = lower_bound(all(nc[inn[j]]), j) - bg(nc[inn[j]]); if (p1 - f1 < f2 - p2) { // there is no way to set up the diagonals such that no matter which way you go its n^2 for (int el = f1; el < p1; el++) { int i = pc[inp[j]][el]; int dist = j - i; if (j + h[i] >= n || h[j + h[i]] != dist) continue; ans++; } } else { for (int el = p2 + 1; el < f2; el++) { int k = nc[inn[j]][el]; int dist = k - j; if (j - h[k] < 0 || h[j - h[k]] != dist) continue; ans++; } } } return ans; } vi best_window(int K) { vi cur = {27, 4, 29, 2, 7, 8, 9, 6, 3, 4, 5, 6, 15, 2, 17, 14, 11, 12, 13, 8, 9, 6, 7, 8, 7, 14, 21, 12, 1, 2, 1, 16, 15, 6, 5, 4, 7, 10, 9, 8, 43, 36, 41, 4, 39, 32, 31, 36, 35, 34, 33, 50, 25, 48, 23, 28, 27, 26, 43, 42, 59, 22, 15, 48, 37, 36, 35, 52, 71, 42, 69, 40, 67, 46, 27, 64, 63, 62, 61, 32, 3, 70, 81, 56, 55, 54, 89, 76, 87, 74, 85, 86, 9, 82, 81, 80, 67, 66, 97, 12, 95, 74, 73, 72, 73, 90, 5, 68, 31, 112, 9, 28, 83, 108, 85, 84, 105, 104, 103, 122, 19, 120, 125, 118, 97, 96, 95, 122, 113, 46, 119, 126, 117, 116, 107, 106, 105, 110, 111, 110, 109, 22, 115, 114, 113, 172, 131, 28, 101, 72, 49, 12, 69, 124, 153, 44, 151, 18, 19, 82, 147, 156, 79, 86, 153, 82, 151, 90, 139, 6, 87, 70, 145, 144, 143, 74, 171, 28, 139, 78, 41, 166, 135, 64, 65, 10, 9, 160, 159, 158, 51, 186, 29, 54, 55, 112, 181, 120, 23, 22, 117, 190, 39, 174, 173, 42, 43, 202, 33, 108, 47, 36, 37, 36, 209, 132, 41, 206, 191, 204, 189, 1, 27, 84, 123, 198, 197, 196, 89, 214, 147, 10, 227, 114, 13, 14, 207, 222, 221, 18, 77, 66, 65, 104, 215, 4, 71, 70, 1, 8, 173, 56, 5, 4, 93, 92, 61, 35, 119, 18, 183, 86, 161, 180, 43, 126, 261, 166, 191, 48, 107, 188, 171, 74, 135, 248, 101, 250, 249, 38, 179, 142, 35, 34, 63, 238, 123, 30, 259, 258, 261, 152, 117, 130, 53, 266, 265, 50, 49, 124, 123, 304, 45, 140, 129, 300, 85, 28, 297, 134, 295, 148, 65, 64, 213, 94, 289, 142, 287, 242, 71, 202, 101, 318, 223, 84, 279, 132, 81, 80, 333, 230, 15, 76, 329, 88, 87, 326, 325, 324, 83, 264, 101, 204, 261, 318, 97, 30, 337, 174, 109, 176, 175, 252, 105, 192, 329, 328, 101, 354, 345, 186, 15, 46, 349, 58, 339, 338, 193, 342, 53, 342, 233, 290, 153, 58, 329, 117, 31, 332, 63, 370, 281, 368, 221, 38, 137, 140, 71, 362, 215, 360, 135, 16, 153, 48, 155, 150, 149, 352, 23, 262, 145, 56, 157, 156, 305, 306, 233, 152, 33, 410, 273, 192, 337, 410, 7, 334, 41, 244, 103, 12, 105, 182, 261, 396, 325, 178, 5, 266, 255, 174, 115, 10, 25, 260, 259, 90, 423, 122, 265, 18, 221, 268, 269, 306, 415, 100, 71, 192, 255, 8, 211, 232, 107, 208, 207, 294, 237, 76, 203, 144, 85, 288, 287, 382, 245, 218, 227, 92, 439, 214, 223, 232, 373, 52, 129, 228, 69, 162, 231, 232, 343, 40, 227, 62, 265, 64, 387, 30, 173, 114, 69, 34, 147, 52, 255, 64, 323, 252, 251, 184, 59, 44, 247, 158, 189, 98, 313, 132, 51, 194, 349, 486, 91, 198, 169, 490, 343, 86, 143, 174, 347, 302, 81, 116, 179, 136, 333, 182, 183, 290, 73, 292, 217, 286, 127, 10, 437, 282, 21, 320, 367, 120, 17, 168, 229, 138, 115, 202, 91, 310, 143, 110, 131, 306, 5, 382, 317, 136, 151, 102, 313, 306, 141, 344, 39, 144, 145, 252, 23, 254, 113, 140, 131, 334, 29, 118, 135, 330, 171, 418, 123, 22, 237, 126, 127, 164, 339, 272, 349, 416, 159, 70, 47, 68, 279, 154, 341, 222, 5, 40, 179, 428, 257, 58, 79, 56, 367, 86, 389, 84, 51, 296, 91, 206, 69, 208, 95, 92, 93, 74, 199, 18, 201, 384, 79, 386, 311, 82, 83, 382, 189, 72, 29, 226, 395, 76, 75, 112, 181, 76, 219, 296, 387, 40, 329, 214, 189, 102, 45, 304, 11, 194, 127, 50, 95, 340, 53, 54, 201, 314, 345, 22, 117, 348, 243, 208, 27, 362, 151, 110, 149, 32, 357, 252, 35, 36, 73, 16, 333, 258, 273, 164, 137, 242, 139, 24, 25, 342, 5, 130, 169, 234, 167, 10, 55, 150, 13, 240, 5, 174, 311, 8, 157, 76, 155, 44, 3, 4, 287, 164, 1, 108, 195, 110, 293, 258, 33, 56, 311, 278, 59, 28, 265, 202, 121, 304, 23, 270, 307, 90, 19, 128, 275, 174, 277, 190, 43, 98, 135, 214, 79, 196, 81, 286, 35, 34, 289, 226, 189, 110, 157, 68, 235, 70, 233, 152, 63, 240, 65, 214, 99, 58, 245, 60, 55, 54, 57, 106, 243, 76, 167, 88, 63, 134, 71, 230, 83, 252, 233, 75, 255, 78, 143, 90, 35, 74, 37, 242, 149, 240, 245, 82, 81, 132, 235, 112, 157, 48, 25, 138, 107, 22, 209, 200, 55, 102, 167, 204, 99, 116, 127, 62, 33, 174, 111, 122, 213, 156, 107, 40, 117, 2, 183, 114, 113, 186, 47, 8, 79, 168, 107, 122, 13, 140, 195, 152, 175, 88, 135, 20, 157, 18, 131, 94, 161, 184, 27, 164, 25, 156, 147, 102, 159, 144, 151, 152, 173, 154, 79, 14, 151, 168, 179, 44, 171, 42, 163, 174, 119, 160, 159, 36, 53, 124, 51, 166, 97, 128, 59, 130, 57, 130, 59, 24, 113, 40, 67, 108, 65, 140, 17, 46, 33, 114, 59, 116, 77, 28, 39, 26, 41, 128, 35, 84, 125, 32, 47, 88, 89, 64, 87, 92, 93, 94, 91, 96, 57, 94, 99, 84, 75, 76, 15, 50, 105, 80, 103, 108, 69, 106, 23, 6, 73, 74, 61, 76, 69, 92, 65, 66, 33, 68, 69, 98, 85, 8, 127, 88, 125, 24, 91, 78, 45, 3, 81, 18, 49, 50, 51, 52, 35, 36, 25, 10, 39, 40, 29, 30, 61, 28, 33, 34, 35, 36, 37, 22, 35, 52, 25, 26, 55, 28, 29, 46, 11, 12, 49, 53, 15, 16, 17, 38, 19, 59, 41, 19, 1, 44, 11, 65, 5, 28, 5, 8, 7, 68, 1, 34, 3, 2, 1, 34, 17, 16, 80, 20, 19, 12, 11, 22, 9, 14, 13, 12, 17, 91, 15, 93, 6, 67, 4, 9, 3, 7, 39, 6, 2, 3, 3, 13, 33, 19, 31, 9, 22, 19, 20, 13, 22, 15, 16, 22, 12, 13, 19, 15, 4, 16, 6, 7, 34, 39, 2, 37, 30, 1, 15, 33, 2, 47, 30, 45, 1, 21, 140, 41, 24, 43, 38, 15, 14, 147, 18, 17, 32, 15, 34, 153, 28, 67, 26, 65, 28, 27, 47, 61, 170, 3, 58, 65, 15, 61, 62, 69, 52, 11, 80, 13, 8, 45, 46, 45, 86, 73, 80, 49, 82, 77, 2, 93, 94, 1, 96, 89, 90, 31, 92, 101, 28, 65, 64, 97, 80, 81, 94, 83, 20, 103, 74, 75, 88, 77, 76, 43, 50, 119, 82, 81, 46, 115, 90, 35, 88, 59, 60, 39, 62, 57, 106, 59, 4, 67, 102, 137, 64, 49, 46, 133, 4, 49, 130, 15, 56, 109, 54, 19, 124, 21, 62, 15, 60, 17, 118, 117, 28, 29, 8, 31, 24, 25, 74, 27, 36, 21, 31, 23, 32, 103, 42, 83, 100, 81, 38, 9, 10, 7, 12, 21, 92, 91, 54, 17, 18, 1, 50, 3, 2, 23, 62, 63, 8, 7, 58, 5, 52, 39, 14, 13, 72, 11, 10, 33, 68, 47, 6, 41, 64, 43, 26, 25, 28, 23, 9, 57, 32, 31, 18, 53, 34, 31, 32, 18, 12, 20, 26, 27, 44, 43, 18, 41, 20, 21, 11, 6, 36, 4, 33, 6, 11, 36, 30, 2, 8, 9, 5, 18, 3, 16, 21, 18, 19, 12, 18, 10, 15, 12, 13, 18, 27, 16, 10, 9, 23, 9, 21, 2, 3, 18, 29, 6, 27, 4, 3, 24, 11, 29, 9, 8, 47, 48, 5, 54, 43, 44, 41, 42, 11, 48, 39, 46, 111, 6, 43, 90, 31, 32, 29, 28, 67, 36, 25, 26, 63, 40, 61, 20, 21, 76, 105, 34, 25, 72, 15, 70, 51, 84, 85, 48, 91, 80, 81, 78, 79, 60, 85, 40, 83, 6, 85, 54, 5, 68, 69, 66, 49, 66, 73, 62, 63, 70, 43, 72, 57, 58, 69, 20, 19, 62, 51, 52, 15, 120, 121, 56, 29, 116, 117, 114, 115, 24, 111, 112, 37, 38, 37, 9, 10, 104, 33, 102, 101, 15, 37, 98, 9, 1, 14, 80, 93, 94, 6, 5, 17, 18, 10, 9, 9, 22, 32, 3, 4, 8, 9, 1, 8, 14, 13, 23, 73, 72, 1, 45, 46, 68, 5, 4, 32, 33, 32, 8, 36, 37, 36, 27, 58, 41, 30, 23, 53, 54, 26, 27, 46, 49, 48, 31, 45, 44, 72, 43, 10, 37, 40, 39, 14, 36, 35, 63, 62, 1, 31, 32, 86, 57, 70, 71, 70, 53, 8, 40, 64, 77, 76, 79, 60, 61, 100, 71, 10, 73, 40, 67, 54, 69, 108, 91, 90, 47, 48, 31, 30, 85, 1, 99, 26, 81, 56, 37, 38, 93, 34, 33, 34, 89, 44, 111, 46, 41, 40, 43, 42, 105, 24, 21, 22, 101, 76, 59, 58, 27, 28, 55, 54, 129, 128, 67, 66, 7, 8, 63, 62, 6, 7, 119, 14, 1, 16, 26, 1, 14, 6, 7, 6, 9, 8, 20, 7, 1, 28, 3, 2, 14, 13, 28, 62, 21, 36, 20, 19, 6, 92, 15, 14, 29, 12, 28, 27, 14, 48, 23, 22, 46, 20, 8, 21, 41, 40, 40, 39, 14, 15, 56, 34, 58, 8, 60, 66, 50, 49, 52, 51, 54, 53, 59, 58, 42, 20, 60, 59, 46, 75, 36, 50, 38, 79, 40, 69, 68, 29, 84, 73, 86, 87, 32, 61, 78, 77, 80, 81, 80, 55, 82, 30, 70, 59, 72, 73, 10, 103, 64, 53, 66, 67, 108, 97, 96, 97, 20, 45, 102, 101, 4, 89, 106, 105, 108, 107, 94, 83, 84, 33, 6, 36, 88, 115, 38, 131, 40, 41, 94, 15, 80, 125, 124, 19, 28, 9, 30, 31, 24, 117, 26, 27, 80, 57, 18, 111, 20, 21, 62, 23, 44, 105, 66, 9, 68, 11, 12, 43, 52, 7, 8, 49, 48, 37, 2, 3, 52, 1, 42, 25, 2, 85, 28, 29, 48, 7, 24, 33, 16, 18, 14, 19, 20, 17, 16, 71, 24, 35, 22, 21, 28, 65, 30, 25, 28, 27, 14, 3, 4, 38, 56, 1, 5, 35, 52, 5, 4, 42, 11, 47, 28, 45, 44, 6, 4, 18, 6, 20, 21, 19, 2, 18, 25, 16, 14, 31, 29, 20, 28, 27, 8, 24, 71, 23, 37, 2, 3, 18, 1, 17, 7, 14, 5, 4, 11, 26, 9, 50, 87, 22, 53, 4, 45, 56, 57, 48, 20, 60, 51, 52, 63, 42, 35, 8, 45, 58, 69, 30, 71, 42, 33, 64, 25, 66, 35, 28, 21, 58, 31, 24, 43, 42, 27, 28, 51, 88, 49, 48, 51, 34, 83, 44, 95, 46, 97, 40, 77, 90, 101, 92, 3, 104, 105, 106, 7, 68, 3, 100, 101, 90, 63, 104, 75, 106, 117, 118, 19, 70, 21, 112, 113, 66, 13, 86, 15, 106, 107, 80, 81, 6, 75, 76, 77, 86, 97, 38, 97, 2, 35, 92, 93, 32, 45, 88, 89, 42, 7, 44, 39, 38, 41, 48, 55, 56, 19, 52, 17, 48, 49, 50, 49, 26, 53, 24, 67, 26, 43, 64, 65, 30, 61, 62, 37, 34, 35, 40, 23, 42, 55, 40, 7, 28, 9, 48, 49, 46, 47, 4, 15, 2, 17, 18, 39, 6, 21, 4, 23, 10, 11, 8, 9, 14, 29, 30, 5, 14, 1, 2, 1, 22, 23, 20, 21, 6, 5, 16, 17, 2, 13, 12, 11, 12, 4, 8, 9, 6, 7, 5, 4, 3, 8, 9, 1, 11, 10, 13, 12, 15, 6, 17, 8, 3, 10, 11, 12, 7, 2, 9, 4, 5, 6, 3, 4, 1, 2, 1, 8}; int M = cur.size(); deque<int> window; for (int i = 0; i < K; i++) window.push_back(cur[i]); int best = count_triples(vi(all(window))); int bk = K-1; for (int i = K; i < M; i++) { window.pop_front(); window.push_back(cur[i]); int ac = count_triples(vi(all(window))); if (ac > best) { bk = i; best = ac; } } vi ans; FOR(i, bk - K+1, bk +1) ans.pb(cur[i]); cerr << "Best window had " << count_triples(ans) << " triples.\n"; trace(ans); cout << "\n"; return ans; } bool accept(double cur_score, double next_score, double temp, mt19937 &rng) { if (next_score > cur_score) return true; cur_score = -cur_score; next_score = -next_score; double prob = exp(-(next_score - cur_score) / temp); return generate_canonical<double, 53>(rng) < prob; } vi construct_range(int M, int K) { vi prev_best = {27, 4, 29, 2, 7, 8, 9, 6, 3, 4, 5, 6, 15, 2, 17, 14, 11, 12, 13, 8, 9, 6, 7, 8, 7, 14, 21, 12, 1, 2, 1, 16, 15, 6, 5, 4, 7, 10, 9, 8, 43, 36, 41, 4, 39, 32, 31, 36, 35, 34, 33, 50, 25, 48, 23, 28, 27, 26, 43, 42, 59, 22, 15, 48, 37, 36, 35, 52, 71, 42, 69, 40, 67, 46, 27, 64, 63, 62, 61, 32, 3, 70, 81, 56, 55, 54, 89, 76, 87, 74, 85, 86, 9, 82, 81, 80, 67, 66, 97, 12, 95, 74, 73, 72, 73, 90, 5, 68, 31, 112, 9, 28, 83, 108, 85, 84, 105, 104, 103, 122, 19, 120, 125, 118, 97, 96, 95, 122, 113, 46, 119, 126, 117, 116, 107, 106, 105, 110, 111, 110, 109, 22, 115, 114, 113, 172, 131, 28, 101, 72, 49, 12, 69, 124, 153, 44, 151, 18, 19, 82, 147, 156, 79, 86, 153, 82, 151, 90, 139, 6, 87, 70, 145, 144, 143, 74, 171, 28, 139, 78, 41, 166, 135, 64, 65, 10, 9, 160, 159, 158, 51, 186, 29, 54, 55, 112, 181, 120, 23, 22, 117, 190, 39, 174, 173, 42, 43, 202, 33, 108, 47, 36, 37, 36, 209, 132, 41, 206, 191, 204, 189, 1, 27, 84, 123, 198, 197, 196, 89, 214, 147, 10, 227, 114, 13, 14, 207, 222, 221, 18, 77, 66, 65, 104, 215, 4, 71, 70, 1, 8, 173, 56, 5, 4, 93, 92, 61, 35, 119, 18, 183, 86, 161, 180, 43, 126, 261, 166, 191, 48, 107, 188, 171, 74, 135, 248, 101, 250, 249, 38, 179, 142, 35, 34, 63, 238, 123, 30, 259, 258, 261, 152, 117, 130, 53, 266, 265, 50, 49, 124, 123, 304, 45, 140, 129, 300, 85, 28, 297, 134, 295, 148, 65, 64, 213, 94, 289, 142, 287, 242, 71, 202, 101, 318, 223, 84, 279, 132, 81, 80, 333, 230, 15, 76, 329, 88, 87, 326, 325, 324, 83, 264, 101, 204, 261, 318, 97, 30, 337, 174, 109, 176, 175, 252, 105, 192, 329, 328, 101, 354, 345, 186, 15, 46, 349, 58, 339, 338, 193, 342, 53, 342, 233, 290, 153, 58, 329, 117, 31, 332, 63, 370, 281, 368, 221, 38, 137, 140, 71, 362, 215, 360, 135, 16, 153, 48, 155, 150, 149, 352, 23, 262, 145, 56, 157, 156, 305, 306, 233, 152, 33, 410, 273, 192, 337, 410, 7, 334, 41, 244, 103, 12, 105, 182, 261, 396, 325, 178, 5, 266, 255, 174, 115, 10, 25, 260, 259, 90, 423, 122, 265, 18, 221, 268, 269, 306, 415, 100, 71, 192, 255, 8, 211, 232, 107, 208, 207, 294, 237, 76, 203, 144, 85, 288, 287, 382, 245, 218, 227, 92, 439, 214, 223, 232, 373, 52, 129, 228, 69, 162, 231, 232, 343, 40, 227, 62, 265, 64, 387, 30, 173, 114, 69, 34, 147, 52, 255, 64, 323, 252, 251, 184, 59, 44, 247, 158, 189, 98, 313, 132, 51, 194, 349, 486, 91, 198, 169, 490, 343, 86, 143, 174, 347, 302, 81, 116, 179, 136, 333, 182, 183, 290, 73, 292, 217, 286, 127, 10, 437, 282, 21, 320, 367, 120, 17, 168, 229, 138, 115, 202, 91, 310, 143, 110, 131, 306, 5, 382, 317, 136, 151, 102, 313, 306, 141, 344, 39, 144, 145, 252, 23, 254, 113, 140, 131, 334, 29, 118, 135, 330, 171, 418, 123, 22, 237, 126, 127, 164, 339, 272, 349, 416, 159, 70, 47, 68, 279, 154, 341, 222, 5, 40, 179, 428, 257, 58, 79, 56, 367, 86, 389, 84, 51, 296, 91, 206, 69, 208, 95, 92, 93, 74, 199, 18, 201, 384, 79, 386, 311, 82, 83, 382, 189, 72, 29, 226, 395, 76, 75, 112, 181, 76, 219, 296, 387, 40, 329, 214, 189, 102, 45, 304, 11, 194, 127, 50, 95, 340, 53, 54, 201, 314, 345, 22, 117, 348, 243, 208, 27, 362, 151, 110, 149, 32, 357, 252, 35, 36, 73, 16, 333, 258, 273, 164, 137, 242, 139, 24, 25, 342, 5, 130, 169, 234, 167, 10, 55, 150, 13, 240, 5, 174, 311, 8, 157, 76, 155, 44, 3, 4, 287, 164, 1, 108, 195, 110, 293, 258, 33, 56, 311, 278, 59, 28, 265, 202, 121, 304, 23, 270, 307, 90, 19, 128, 275, 174, 277, 190, 43, 98, 135, 214, 79, 196, 81, 286, 35, 34, 289, 226, 189, 110, 157, 68, 235, 70, 233, 152, 63, 240, 65, 214, 99, 58, 245, 60, 55, 54, 57, 106, 243, 76, 167, 88, 63, 134, 71, 230, 83, 252, 233, 75, 255, 78, 143, 90, 35, 74, 37, 242, 149, 240, 245, 82, 81, 132, 235, 112, 157, 48, 25, 138, 107, 22, 209, 200, 55, 102, 167, 204, 99, 116, 127, 62, 33, 174, 111, 122, 213, 156, 107, 40, 117, 2, 183, 114, 113, 186, 47, 8, 79, 168, 107, 122, 13, 140, 195, 152, 175, 88, 135, 20, 157, 18, 131, 94, 161, 184, 27, 164, 25, 156, 147, 102, 159, 144, 151, 152, 173, 154, 79, 14, 151, 168, 179, 44, 171, 42, 163, 174, 119, 160, 159, 36, 53, 124, 51, 166, 97, 128, 59, 130, 57, 130, 59, 24, 113, 40, 67, 108, 65, 140, 17, 46, 33, 114, 59, 116, 77, 28, 39, 26, 41, 128, 35, 84, 125, 32, 47, 88, 89, 64, 87, 92, 93, 94, 91, 96, 57, 94, 99, 84, 75, 76, 15, 50, 105, 80, 103, 108, 69, 106, 23, 6, 73, 74, 61, 76, 69, 92, 65, 66, 33, 68, 69, 98, 85, 8, 127, 88, 125, 24, 91, 78, 45, 3, 81, 18, 49, 50, 51, 52, 35, 36, 25, 10, 39, 40, 29, 30, 61, 28, 33, 34, 35, 36, 37, 22, 35, 52, 25, 26, 55, 28, 29, 46, 11, 12, 49, 53, 15, 16, 17, 38, 19, 59, 41, 19, 1, 44}; vi ret; while (int(ret.size()) < M) { for (auto &el : prev_best) { ret.pb(el); if (ret.size() >= M) break; } } return ret; // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // uniform_int_distribution u(0, M-1); // geometric_distribution<int> g(0.4); // double lambda = 0.01; vector<double> w(M); for (int i = 0; i < M; i++) w[i] = exp(-lambda * i); // discrete_distribution<int> d(all(w)); // vi cur, best; while (int(cur.size()) < M) {int x = prev_best[cur.size()]; cur.pb(x); best.pb(x);} // best_window(500); // int score = count_triples(cur), best_score = count_triples(best); // score = 0; // // double T = 10000, u = 0.9995; // double t0 = 100.0; double c = 0.85; // int trials = 1; // // while (T > 1) { // while(best_score < K) { // if (trials % 25000 == 0) cerr << "Trials: " << trials << " Best: " << best_score << "\n"; // if (trials % CHECK_EVERY == 0) save_checkpoint(CHECKPOINT_PATH, best, best_score, trials); // double T = c / log(t0 + double(trials/2)); // vi nxt = cur; // int idx = u(rng); // // int val = g(rng) + 1; while (val >= M) val = g(rng) + 1; // int val = d(rng); while (!(1 <= val && val < M)) val = d(rng); // nxt[idx] = val; // int ns = count_triples(nxt); // if (accept(score, ns, T, rng)) { // score = ns; cur = nxt; // if (ns > best_score) { // best_score = ns; best = nxt; // } // } // // T *= u; // trials++; // } // cerr << "Array has: " << count_triples(best) << " triples.\n"; // return best; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...