Submission #1175541

#TimeUsernameProblemLanguageResultExecution timeMemory
1175541ortsacBroken Device (JOI17_broken_device)C++20
85 / 100
20 ms1604 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; #define int long long #define fr first #define se second void Anna(int32_t n, int x, int32_t k, int32_t p[]) { vector<pair<int, int>> pares = {{35, 26}, {91, 115}, {30, 59}, {89, 135}, {103, 146}, {118, 73}, {17, 45}, {99, 72}, {13, 2}, {137, 42}, {105, 116}, {67, 8}, {55, 11}, {85, 142}, {44, 80}, {148, 65}, {100, 18}, {88, 123}, {98, 96}, {93, 130}, {147, 0}, {144, 57}, {131, 15}, {109, 49}, {5, 22}, {108, 48}, {75, 129}, {110, 28}, {92, 94}, {81, 7}, {63, 31}, {53, 128}, {43, 6}, {117, 54}, {127, 24}, {69, 133}, {107, 120}, {40, 60}, {149, 82}, {136, 68}, {4, 126}, {12, 119}, {141, 21}, {64, 106}, {87, 20}, {102, 77}, {1, 113}, {143, 33}, {56, 62}, {38, 41}, {36, 16}, {104, 139}, {71, 34}, {19, 140}, {90, 9}, {97, 86}, {145, 125}, {39, 121}, {14, 23}, {83, 112}, {61, 114}, {70, 32}, {10, 51}, {132, 52}, {111, 74}, {101, 84}, {58, 95}, {66, 46}, {25, 134}, {76, 78}, {122, 124}, {47, 37}, {3, 29}, {79, 50}, {138, 27}}; vector<int> ans(150); vector<int> broken(150); for (int i = 0; i < k; i++) broken[p[i]] = 1; vector<int> pow3(38); pow3[0] = 1; for (int i = 1; i < 38; i++) pow3[i] = (3 * pow3[i - 1]); int curr = 0; vector<int> touched(150); //cout << "oi\n"; for (int i = 37; i >= 0; i--) { while ((curr < 75) && (broken[pares[curr].first] || broken[pares[curr].second])) { curr++; } if (curr >= 75) break; //cout << i << "\n"; int qtd = 1; while (x >= pow3[i]) { qtd++; x -= pow3[i]; } int b0 = (qtd % 2); qtd /= 2; int b1 = (qtd % 2); ans[pares[curr].first] = b0; ans[pares[curr].second] = b1; curr++; } //cout << "ok\n"; for (int i = 0; i < 75; i++) { auto u = pares[i]; //cout << i << " " << touched[u.fr] << " " << touched[u.se] << "\n"; } //cout << "done\n"; for (int i = 0; i < 150; i++) { Set(i, ans[i]); } }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; #define int long long #define fr first #define se second int Bruno(int32_t n, int32_t a[] ) { vector<pair<int, int>> pares = {{35, 26}, {91, 115}, {30, 59}, {89, 135}, {103, 146}, {118, 73}, {17, 45}, {99, 72}, {13, 2}, {137, 42}, {105, 116}, {67, 8}, {55, 11}, {85, 142}, {44, 80}, {148, 65}, {100, 18}, {88, 123}, {98, 96}, {93, 130}, {147, 0}, {144, 57}, {131, 15}, {109, 49}, {5, 22}, {108, 48}, {75, 129}, {110, 28}, {92, 94}, {81, 7}, {63, 31}, {53, 128}, {43, 6}, {117, 54}, {127, 24}, {69, 133}, {107, 120}, {40, 60}, {149, 82}, {136, 68}, {4, 126}, {12, 119}, {141, 21}, {64, 106}, {87, 20}, {102, 77}, {1, 113}, {143, 33}, {56, 62}, {38, 41}, {36, 16}, {104, 139}, {71, 34}, {19, 140}, {90, 9}, {97, 86}, {145, 125}, {39, 121}, {14, 23}, {83, 112}, {61, 114}, {70, 32}, {10, 51}, {132, 52}, {111, 74}, {101, 84}, {58, 95}, {66, 46}, {25, 134}, {76, 78}, {122, 124}, {47, 37}, {3, 29}, {79, 50}, {138, 27}}; int curr = 37; vector<int> pow3(38); pow3[0] = 1; int ans = 0; for (auto u : pares) { //cout << a[u.fr] << " " << a[u.se] << "\n"; } for (int i = 1; i < 38; i++) pow3[i] = (3 * pow3[i - 1]); for (int i = 0; i < (n/2); i++) { if (a[pares[i].fr] | a[pares[i].se]) { int qtd = -1; qtd += (a[pares[i].fr]); qtd += (2*a[pares[i].se]); ans += (qtd * pow3[curr]); //cout << qtd << "\n"; curr--; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...