# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
363359 | denkendoemeer | Broken Device (JOI17_broken_device) | C++14 | 55 ms | 3076 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>
#define ll long long
#include "Annalib.h"
using namespace std;
pair<int,int>val(int x)
{
if (x==0)
return {0,1};
if (x==1)
return {1,0};
return {1,1};
}
void Anna(int n,ll x,int k,int p[])
{
srand(time(0));
vector<int>aux(n);
int i;
for(i=0;i<n;i++)
aux[i]=i;
random_shuffle(aux.begin(),aux.end());
vector<bool>poz(n,0),ans(n);
for(i=0;i<k;i++)
poz[p[i]]=1;
for(i=0;i<n;i+=2){
auto num=val(x%3);
if ((poz[aux[i]]==0 || num.first==0) && (poz[aux[i+1]]==0 && num.second==0)){
ans[aux[i]]=num.first;
ans[aux[i+1]]=num.second;
x=x/3;
}
}
for(i=0;i<n;i++)
Set(i,ans[i]);
}
#include<bits/stdc++.h>
#define ll long long
#include "Brunolib.h"
using namespace std;
int val(pair<int,int>num)
{
if (num.first+num.second==2)
return 2;
return num.first;
}
ll Bruno(int n,int a[])
{
srand(time(0));
vector<int>aux(n);
int i;
for(i=0;i<n;i++)
aux[i]=i;
random_shuffle(aux.begin(),aux.end());
ll ans=0,po=1;
for(i=0;i<n;i+=2){
if (a[aux[i]] || a[aux[i+1]]){
ans=ans+po*val({a[aux[i]],a[aux[i+1]]});
po=po*3;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |