제출 #1262066

#제출 시각아이디문제언어결과실행 시간메모리
1262066M_W_13Broken Device (JOI17_broken_device)C++20
85 / 100
25 ms1500 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define st first #define nd second #define pb push_back void Anna(int N, long long X, int K, int P[] ){ vector<int> pom = {5, 42, 85, 11, 94, 143, 86, 92, 84, 117, 148, 139, 104, 19, 1, 54, 93, 90, 13, 79, 99, 24, 49, 45, 55, 114, 10, 131, 126, 38, 50, 65, 23, 7, 43, 14, 97, 17, 75, 136, 74, 98, 3, 120, 100, 130, 116, 46, 107, 18, 132, 6, 146, 137, 119, 39, 31, 135, 61, 110, 87, 67, 72, 41, 16, 118, 106, 69, 95, 29, 44, 60, 37, 144, 8, 0, 91, 64, 15, 83, 125, 129, 52, 88, 36, 113, 12, 77, 78, 22, 51, 82, 140, 103, 62, 70, 121, 57, 32, 34, 27, 124, 33, 2, 47, 96, 66, 71, 109, 138, 80, 105, 112, 134, 4, 141, 76, 108, 122, 59, 28, 89, 35, 123, 9, 48, 149, 58, 142, 115, 63, 68, 26, 145, 20, 128, 21, 111, 102, 73, 30, 147, 56, 101, 81, 40, 25, 53, 133, 127}; queue<ll> vec; rep(i, 38) { vec.push(X % 3ll); X /= 3ll; } int pol = N/2; bool czy[N]; rep(i, N) { czy[i] = true; } rep(i, K) { int x = P[i]; czy[x] = false; } for (int i = 0; i < N; i += 2) { int a = pom[i]; int b = pom[i + 1]; if (czy[a] && czy[b]) { if (vec.empty()) { Set(a, 0); Set(b, 0); } else { ll p = vec.front(); vec.pop(); if (p == 0) { Set(a, 0); Set(b, 1); } else if (p == 1) { Set(a, 1); Set(b, 0); } else { Set(a, 1); Set(b, 1); } } } else { Set(a, 0); Set(b, 0); } } }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define st first #define nd second #define pb push_back long long Bruno( int N, int A[] ){ vector<int> pom = {5, 42, 85, 11, 94, 143, 86, 92, 84, 117, 148, 139, 104, 19, 1, 54, 93, 90, 13, 79, 99, 24, 49, 45, 55, 114, 10, 131, 126, 38, 50, 65, 23, 7, 43, 14, 97, 17, 75, 136, 74, 98, 3, 120, 100, 130, 116, 46, 107, 18, 132, 6, 146, 137, 119, 39, 31, 135, 61, 110, 87, 67, 72, 41, 16, 118, 106, 69, 95, 29, 44, 60, 37, 144, 8, 0, 91, 64, 15, 83, 125, 129, 52, 88, 36, 113, 12, 77, 78, 22, 51, 82, 140, 103, 62, 70, 121, 57, 32, 34, 27, 124, 33, 2, 47, 96, 66, 71, 109, 138, 80, 105, 112, 134, 4, 141, 76, 108, 122, 59, 28, 89, 35, 123, 9, 48, 149, 58, 142, 115, 63, 68, 26, 145, 20, 128, 21, 111, 102, 73, 30, 147, 56, 101, 81, 40, 25, 53, 133, 127}; ll x = 0; ll pot = 1; for (int i = 0; i < N; i += 2) { int a = pom[i]; int b = pom[i + 1]; if (A[a] == 1 && A[b] == 0) { x += pot; } else if (A[a] == 1 && A[b] == 1) { x += (2ll * pot); } if (A[a] == 0 && A[b] == 0) { continue; } pot *= 3ll; } // cout << "x = " << x << '\n'; return x; }
#Verdict Execution timeMemoryGrader output
Fetching results...