Submission #131731

#TimeUsernameProblemLanguageResultExecution timeMemory
131731zoooma13Broken Device (JOI17_broken_device)C++14
85 / 100
60 ms3064 KiB
#include "bits/stdc++.h" #include "Annalib.h" using namespace std; vector <int> tobase3(long long X){ vector <int> ret; while(X){ ret.push_back(X%3); X /= 3; } return ret; } pair<int ,int> en(int num){ return num == 2 ? make_pair(1 ,1) : (num == 1 ? make_pair(1 ,0) : make_pair(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 <pair<int ,int>> ps; for(int i=0; i<N; i+=2) if(!bad[ord[i]] && !bad[ord[i+1]]) ps.push_back({ord[i] ,ord[i+1]}); vector <int> bs3 = tobase3(X); int j = 0; vector <int> enc(N ,0); for(auto&p : ps){ if(j >= bs3.size()) break; auto d = en(bs3[j++]); enc[p.first] = d.first; enc[p.second] = d.second; } for(int i=0; i<N; i++) Set(i ,enc[i]); //assert(false); }
#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()); vector <pair<int ,int>> ps; for(int i=0; i<N; i+=2) if(A[ord[i]] || A[ord[i+1]]) ps.push_back({ord[i] ,ord[i+1]}); int j = 0; long long X = 0LL ,pw = 1LL; for(auto&p : ps){ X += pw*de({A[p.first] ,A[p.second]}); pw *= 3; } return X; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:37:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(j >= bs3.size())
            ~~^~~~~~~~~~~~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:19:9: warning: unused variable 'j' [-Wunused-variable]
     int j = 0;
         ^
#Verdict Execution timeMemoryGrader output
Fetching results...