Submission #991263

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