제출 #1175478

#제출 시각아이디문제언어결과실행 시간메모리
1175478ortsacBroken Device (JOI17_broken_device)C++20
90 / 100
20 ms1576 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 = {{131, 107}, {97, 9}, {55, 147}, {84, 134}, {57, 80}, {142, 116}, {4, 125}, {24, 72}, {6, 117}, {14, 70}, {104, 15}, {47, 102}, {31, 133}, {54, 145}, {106, 129}, {146, 132}, {140, 93}, {7, 1}, {52, 78}, {35, 18}, {40, 22}, {61, 73}, {94, 69}, {118, 56}, {41, 137}, {38, 121}, {46, 100}, {105, 92}, {123, 120}, {128, 135}, {66, 108}, {64, 62}, {17, 10}, {144, 39}, {67, 76}, {114, 86}, {0, 81}, {89, 2}, {115, 90}, {83, 44}, {23, 138}, {37, 139}, {96, 126}, {28, 13}, {48, 33}, {45, 112}, {99, 50}, {149, 51}, {29, 91}, {60, 63}, {143, 101}, {43, 124}, {49, 122}, {8, 127}, {74, 75}, {79, 71}, {111, 25}, {20, 3}, {148, 141}, {11, 42}, {136, 65}, {77, 30}, {98, 110}, {130, 26}, {119, 53}, {5, 88}, {109, 68}, {21, 59}, {27, 19}, {87, 12}, {16, 36}, {113, 103}, {58, 34}, {95, 85}, {82, 32}}; 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 = {{131, 107}, {97, 9}, {55, 147}, {84, 134}, {57, 80}, {142, 116}, {4, 125}, {24, 72}, {6, 117}, {14, 70}, {104, 15}, {47, 102}, {31, 133}, {54, 145}, {106, 129}, {146, 132}, {140, 93}, {7, 1}, {52, 78}, {35, 18}, {40, 22}, {61, 73}, {94, 69}, {118, 56}, {41, 137}, {38, 121}, {46, 100}, {105, 92}, {123, 120}, {128, 135}, {66, 108}, {64, 62}, {17, 10}, {144, 39}, {67, 76}, {114, 86}, {0, 81}, {89, 2}, {115, 90}, {83, 44}, {23, 138}, {37, 139}, {96, 126}, {28, 13}, {48, 33}, {45, 112}, {99, 50}, {149, 51}, {29, 91}, {60, 63}, {143, 101}, {43, 124}, {49, 122}, {8, 127}, {74, 75}, {79, 71}, {111, 25}, {20, 3}, {148, 141}, {11, 42}, {136, 65}, {77, 30}, {98, 110}, {130, 26}, {119, 53}, {5, 88}, {109, 68}, {21, 59}, {27, 19}, {87, 12}, {16, 36}, {113, 103}, {58, 34}, {95, 85}, {82, 32}}; 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...