Submission #131738

#TimeUsernameProblemLanguageResultExecution timeMemory
131738zoooma13Broken Device (JOI17_broken_device)C++14
100 / 100
55 ms3312 KiB
#include "bits/stdc++.h" #include "Annalib.h" using namespace std; vector <int> tobase3(long long x){ vector <int> ret; for( ; x; x/=3) ret.push_back(x%3); return ret; } pair<int ,int> en(int num){ if(num == 2) return {1 ,1}; if(num == 1) return {1 ,0}; return {0 ,1}; } void Anna( int N, long long X, int K, int P[] ){ srand(456132); vector <int> ord(N); iota(ord.begin() ,ord.end() ,0); random_shuffle(ord.begin() ,ord.end()); vector <bool> bad(N, false); for(int i=0; i<K; i++) bad[P[i]] = true; vector <int> enc(N ,0) ,bs3 = tobase3(X); for(int j=0 ,i=0; i<N && j<bs3.size(); i+=2){ auto d = en(bs3[j]); if((!bad[ord[i]] || !d.first) && (!bad[ord[i+1]] || !d.second)){ enc[ord[i]] = d.first; enc[ord[i+1]] = d.second; j++; } } for(int i=0; i<N; i++) Set(i ,enc[i]); }
#include "bits/stdc++.h" #include "Brunolib.h" using namespace std; int de(pair<int ,int> p){ return p.first+p.second == 2 ? 2 : p.first; } long long Bruno( int N, int A[] ){ srand(456132); vector <int> ord(N); iota(ord.begin() ,ord.end() ,0); random_shuffle(ord.begin() ,ord.end()); long long X = 0LL ,pw = 1LL; for(int i=0; i<N; i+=2) if(A[ord[i]] || A[ord[i+1]]){ X += pw*de({A[ord[i]] ,A[ord[i+1]]}); pw *= 3; } return X; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:28:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0 ,i=0; i<N && j<bs3.size(); i+=2){
                              ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...