Submission #260857

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