# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131731 | zoooma13 | Broken Device (JOI17_broken_device) | C++14 | 60 ms | 3064 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |