# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
954904 | Lemser | Broken Device (JOI17_broken_device) | C++14 | 0 ms | 0 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"
#define endl '\n'
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define fore(i,l,r) for(int i=l;i<r;i++)
#define fo(i,n) fore(i,0,n)
#define forex(i,r,l) for(int i=r;i>=l;i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define ll long long
#deifne sz(x) (int)x.size()
using namespace std;
using vi = vector<int>;using ii = pair<int,int>;
ll A[160];
void Set(int idx, int bit ){
A[idx] = bit;
}
string desc(long long X)
{
string resp;
while (X)
{
ll mod = X % 2ll;
if (mod == 1)
{
resp += "1";
}else
{
resp += "0";
}
X /= 2;
}
while (sz(resp) < 60)
{
resp += "0";
}
reverse(resp.begin(), resp.end());
resp += resp;
return resp;
}
void Anna( int N, long long X, int K, int P[] )
{
string num = desc(X);
for( int i = 0; i < 120; i++ )
{
int bit = num[i] - '0';
Set(i, bit);
}
int wrongPos = P[0];
if (wrongPos < 120)
{
wrongPos = 59 - wrongPos;
int r = num[wrongPos] - '0';
Set(120, r);
}else
{
Set(120, 1);
}
for (int i = 121; i < N; i++)
{
Set(i, 1);
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
long long comp(string s)
{
reverse(s.begin(), s.end());
long long resp = 0;
long long p2 = 1;
for (int i = 0; i < (int)s.size(); i++)
{
if (s[i] == '1')
{
resp += p2;
}
p2 *= 2;
}
return resp;
}
long long Bruno( int N, int A[] )
{
string resp;
for (int i = 0; i < 60; i++)
{
if (A[i] == A[i + 60])
{
resp += A[i] +'0';
}else
{
resp += A[120] + '0';
}
}
long long X = comp(resp);
return X;
}