# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
770249 | minhcool | Broken Device (JOI17_broken_device) | C++17 | 37 ms | 2708 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.
//#define local
#ifndef local
#include "Annalib.h"
#endif
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 3e5 + 5;
const int oo = 1e18 + 7, mod = 1e9 + 7;
mt19937 rng(1);
int rnd(int l, int r){
int temp = rng() % (r - l + 1);
return abs(temp) + l;
}
bool out[N];
int arr1[] = {1, 2, 2, 4, 2, 4, 4, 4};
int arr2[] = {0, 0, 0, 0, 1, 1, 2, 3};
int arr3[] = {1, 2, 2, 4, 2, 4, 4, 4};
int arr4[] = {0, 0, 1, 0, 1, 2, 1, 3};
void Anna(int N, long long X, int K, int P[]){
for(int i = 0; i < N; i++) out[i] = 0;
for(int i = 0; i < K; i++) out[P[i]] = 1;
vector<pair<long long, pair<int, int>>> vc;
//cout << X << "\n";
for(int i = 0; i < N; i += 3){
// if(!X) break;
if(!(i % 6)){
int msk = (!out[i]) + (!out[i + 1]) * 2 + (!out[i + 2]) * 4;
int ind = -1;
for(int j = 7; j >= 0; j--){
if((X % arr1[j] == arr2[j]) && ((msk | j) == msk)){
if(ind == -1) ind = j;
if(arr1[ind] < arr1[j]) ind = j;
//break;
}
}
X /= arr1[ind];
// cout << i << " " << ind << "\n";
vc.pb({X, {msk, ind}});
Set(i, ((ind & 1) != 0));
Set(i + 1, ((ind & 2) != 0));
Set(i + 2, ((ind & 4) != 0));
}
else{
int msk = (!out[i]) + (!out[i + 1]) * 2 + (!out[i + 2]) * 4;
int ind = -1;
for(int j = 7; j >= 0; j--){
if((X % arr3[j] == arr4[j]) && ((msk | j) == msk)){
if(ind == -1) ind = j;
if(arr3[ind] < arr3[j]) ind = j;
//break;
}
}
X /= arr3[ind];
// cout << i << " " << ind << "\n";
vc.pb({X, {msk, ind}});
Set(i, ((ind & 1) != 0));
Set(i + 1, ((ind & 2) != 0));
Set(i + 2, ((ind & 4) != 0));
}
//cout << X << " " << ind << "\n";
}
if(X){
//for(auto it : vc) cout << it.fi << " " << it.fi % 4 << " " << it.se.fi << " " << it.se.se << "\n";
//cout << X << "\n";
}
}
#ifdef local
void process(){
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--) process();
}
#endif
//#define local
#ifndef local
#include "Brunolib.h"
#endif
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 3e5 + 5;
const int oo = 1e18 + 7, mod = 1e9 + 7;
//mt19937 rng(1);
int arr11[] = {1, 2, 2, 4, 2, 4, 4, 4};
int arr22[] = {0, 0, 0, 0, 1, 1, 2, 3};
int arr33[] = {1, 2, 2, 4, 2, 4, 4, 4};
int arr44[] = {0, 0, 1, 0, 1, 2, 1, 3};
long long Bruno(int N, int A[]){
long long ans = 0;
for(int i = N - 3; i >= 0; i -= 3){
if(!(i % 6)){
int temp = A[i] + 2 * A[i + 1] + 4 * A[i + 2];
// cout << temp << "\n";
ans = (ans * arr11[temp]) + arr22[temp];
}
else{
int temp = A[i] + 2 * A[i + 1] + 4 * A[i + 2];
// cout << temp << "\n";
ans = (ans * arr33[temp]) + arr44[temp];
}
}
//cout << ans << "\n";
return ans;
}
#ifdef local
void process(){
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--) process();
}
#endif
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |