# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411859 | amoo_safar | Broken Device (JOI17_broken_device) | C++17 | 54 ms | 2460 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 "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
const int Z = 75;
vector< vector<int> > V;
bool init = false;
void Init(){
srand(time(0));
vector<int> per = {0, 1, 2};
for(int i = 0; i < Z; i++){
random_shuffle(per.begin(), per.end());
V.push_back(per);
}
init = true;
}
void Anna( int n, long long X, int K, int P[] ){
if(!init)
Init();
vector<int> mk(n, 0);
for(int i = 0; i < K; i++)
mk[P[i]] = 1;
// for(int i = 0; i < N; i++){
// if(i == N - 1){
// Set(i, 0);
// continue;
// }
// if(mk[i] || mk[i + 1])
// Set(i, 0);
// }
for(int i = 0; i < n; i += 2){
if(mk[i] && mk[i + 1]){
Set(i, 0);
Set(i + 1, 0);
continue;
}
int rt = X % 3;
int idx = 0;
for(int j = 0; j < 3; j++)
if(V[i / 2][j] == rt)
idx = j;
int br = mk[i] + mk[i] + mk[i + 1];
if(br & (idx + 1)){
Set(i, 0);
Set(i + 1, 0);
continue;
}
X /= 3;
// cerr << "# " << idx << '\n';
Set(i, (idx + 1) / 2);
Set(i + 1, (idx + 1) % 2);
}
// cerr << "!! ";
// for(int i = 0; i < 4; i++){
// cerr << "(";
// for(int j = 0; j < 3; j++)
// cerr << V[i][j] << ",)"[j == 2];
// // cerr << '\n';
// }
// cerr << '\n';
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
const int Z = 75;
vector< vector<int> > V2;
bool init2 = false;
void Init2(){
srand(time(0));
vector<int> per = {0, 1, 2};
for(int i = 0; i < Z; i++){
random_shuffle(per.begin(), per.end());
V2.push_back(per);
}
init2 = true;
}
long long Bruno( int n, int A[] ){
if(!init2)
Init2();
long long res = 0;
for(int i = n - 2; i >= 0; i--){
if(A[i] == 0 && A[i + 1] == 0) continue;
int rd = A[i] + A[i] + A[i + 1] - 1;
rd = V2[i / 2][rd];
res *= 3;
res += rd;
}
// cerr << "!! " << res << '\n';
// cerr << "!! ";
// for(int i = 0; i < 4; i++){
// cerr << "(";
// for(int j = 0; j < 3; j++)
// cerr << V2[i][j] << ",)"[j == 2];
// // cerr << '\n';
// }
// cerr << '\n';
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |