Submission #1079168

#TimeUsernameProblemLanguageResultExecution timeMemory
1079168makravBroken Device (JOI17_broken_device)C++14
100 / 100
29 ms3284 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; vector<pair<int, int>> prs = {{4, 28}, {118, 69}, {138, 85}, {30, 65}, {63, 35}, {132, 146}, {56, 10}, {95, 74}, {64, 70}, {125, 128}, {124, 39}, {120, 111}, {80, 29}, {16, 60}, {53, 100}, {26, 136}, {106, 143}, {137, 76}, {123, 45}, {37, 33}, {130, 3}, {2, 59}, {99, 142}, {145, 97}, {68, 83}, {127, 58}, {38, 1}, {62, 114}, {43, 101}, {22, 141}, {103, 131}, {110, 18}, {61, 49}, {115, 0}, {5, 135}, {15, 13}, {86, 34}, {105, 72}, {9, 7}, {126, 88}, {77, 41}, {17, 51}, {133, 50}, {81, 112}, {116, 67}, {96, 24}, {148, 117}, {84, 102}, {144, 19}, {92, 121}, {25, 8}, {75, 52}, {93, 73}, {149, 6}, {20, 48}, {104, 66}, {12, 57}, {91, 147}, {90, 82}, {98, 27}, {21, 139}, {129, 108}, {44, 31}, {89, 134}, {14, 87}, {32, 71}, {55, 122}, {23, 79}, {36, 109}, {78, 113}, {119, 47}, {107, 54}, {42, 40}, {46, 11}, {140, 94}}; vector<vector<int>> lol = {{2,0,1},{1,0,2},{1,2,0},{0,1,2},{2,0,1},{1,0,2},{1,0,2},{2,1,0},{1,0,2},{2,1,0},{0,1,2},{2,1,0},{0,2,1},{1,0,2},{2,1,0},{1,0,2},{2,0,1},{1,0,2},{0,2,1},{0,2,1},{0,1,2},{2,0,1},{0,2,1},{0,1,2},{2,0,1},{2,0,1},{0,2,1},{1,2,0},{0,2,1},{0,1,2},{2,1,0},{0,2,1},{2,0,1},{1,0,2},{2,1,0},{0,1,2},{1,0,2},{2,1,0}}; void Anna( int N, long long X, int K, int P[] ){ vector<int> used(N, 0); for (int i = 0; i < K; i++) used[P[i]] = 1; vector<int> bits; for (int i = 0; i < 38; i++) { bits.push_back(X % 3); X /= 3; } reverse(bits.begin(), bits.end()); int cb = 0; for (int i = 0; i < prs.size(); i++) { if (cb >= 38) { Set(prs[i].first,0); Set(prs[i].second,0);continue; } if (used[prs[i].first] && used[prs[i].second]) { Set(prs[i].first,0);Set(prs[i].second,0);continue; } int ps = 0; for (int j = 0; j < 3; j++) { if (lol[cb][j] == bits[cb]) ps = j; } if (used[prs[i].first]) { if (ps != 0) { Set(prs[i].first,0);Set(prs[i].second,0);continue; } Set(prs[i].second, 1); Set(prs[i].first,0); cb++; } else if (used[prs[i].second]) { if (ps != 1) { Set(prs[i].first,0);Set(prs[i].second,0);continue; } Set(prs[i].first, 1); Set(prs[i].second, 0); cb++; } else { Set(prs[i].second, 1 - ps % 2); Set(prs[i].first, (ps > 0)); cb++; } } }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector<pair<int, int>> prs = {{4, 28}, {118, 69}, {138, 85}, {30, 65}, {63, 35}, {132, 146}, {56, 10}, {95, 74}, {64, 70}, {125, 128}, {124, 39}, {120, 111}, {80, 29}, {16, 60}, {53, 100}, {26, 136}, {106, 143}, {137, 76}, {123, 45}, {37, 33}, {130, 3}, {2, 59}, {99, 142}, {145, 97}, {68, 83}, {127, 58}, {38, 1}, {62, 114}, {43, 101}, {22, 141}, {103, 131}, {110, 18}, {61, 49}, {115, 0}, {5, 135}, {15, 13}, {86, 34}, {105, 72}, {9, 7}, {126, 88}, {77, 41}, {17, 51}, {133, 50}, {81, 112}, {116, 67}, {96, 24}, {148, 117}, {84, 102}, {144, 19}, {92, 121}, {25, 8}, {75, 52}, {93, 73}, {149, 6}, {20, 48}, {104, 66}, {12, 57}, {91, 147}, {90, 82}, {98, 27}, {21, 139}, {129, 108}, {44, 31}, {89, 134}, {14, 87}, {32, 71}, {55, 122}, {23, 79}, {36, 109}, {78, 113}, {119, 47}, {107, 54}, {42, 40}, {46, 11}, {140, 94}}; vector<vector<int>> lol = {{2,0,1},{1,0,2},{1,2,0},{0,1,2},{2,0,1},{1,0,2},{1,0,2},{2,1,0},{1,0,2},{2,1,0},{0,1,2},{2,1,0},{0,2,1},{1,0,2},{2,1,0},{1,0,2},{2,0,1},{1,0,2},{0,2,1},{0,2,1},{0,1,2},{2,0,1},{0,2,1},{0,1,2},{2,0,1},{2,0,1},{0,2,1},{1,2,0},{0,2,1},{0,1,2},{2,1,0},{0,2,1},{2,0,1},{1,0,2},{2,1,0},{0,1,2},{1,0,2},{2,1,0}}; long long Bruno( int N, int A[] ){ int cb = 0; ll ans = 0; for (int i = 0; i < prs.size() && cb < 38; i++) { if (A[prs[i].first] + A[prs[i].second] == 0) continue; if (!A[prs[i].first]) { ans = ans * 3ll + lol[cb++][0]; } else if (!A[prs[i].second]) { ans = ans * 3ll + lol[cb++][1]; } else { ans = ans * 3ll + lol[cb++][2]; } } return ans; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < prs.size(); i++) {
      |                     ~~^~~~~~~~~~~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 0; i < prs.size() && cb < 38; i++) {
      |                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...