Submission #990927

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