# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1208374 | Ghulam_Junaid | Broken Device (JOI17_broken_device) | C++20 | 22 ms | 1344 KiB |
#include <bits/stdc++.h>
#include "Annalib.h"
using namespace std;
typedef long long ll;
void Anna(int n, ll X, int m, int pos[] ){
bool allowed[n] = {};
for (ll i = 0; i < n; i ++)
allowed[i] = 1;
for (ll i = 0; i < m; i ++)
allowed[pos[i]] = 0;
map<ll, string> mp;
mp[0] = "";
mp[1] = "0";
mp[2] = "1";
mp[3] = "10";
mp[4] = "01";
mp[5] = "1";
mp[6] = "00";
mp[7] = "11";
ll b = 0;
for (ll i = 0; i < n; i += 3){
if (b >= 60){
Set(i, 0); Set(i + 1, 0); Set(i + 2, 0);
continue;
}
bool nxt[2] = {((1ll << b) & X), ((1ll << (b + 1)) & X)};
ll best = 0;
ll mask = allowed[i + 2] + 2 * allowed[i + 1] + 4 * allowed[i];
for (ll make = 0; make < 8; make ++){
if (make & mask != make) continue;
bool good = 1;
for (ll j = 0; j < mp[make].size(); j ++)
good &= (nxt[j] == mp[make][j] - '0');
if (good and mp[make].size() > mp[best].size())
best = make;
}
for (ll j = 2; j >= 0; j --){
if ((1ll << j) & best)
Set(i + 2 - j, 1);
else
Set(i + 2 - j, 0);
}
b += mp[best].size();
}
}
/*
10
150 1000000000000000000 10
0 1 2 3 4 5 6 7 8 10
150 102123124767219381 1
0
150 124397182346812734 2
0 1
150 82137459812635685 1
1
150 1 1
1
150 2 1
1
150 3 1
1
150 4 1
1
150 5 1
1
150 6 1
1
*/
#include <bits/stdc++.h>
#include "Brunolib.h"
using namespace std;
typedef long long ll;
ll Bruno(int n, int a[]){
map<ll, string> mp;
mp[0] = "";
mp[1] = "0";
mp[2] = "1";
mp[3] = "10";
mp[4] = "01";
mp[5] = "1";
mp[6] = "00";
mp[7] = "11";
ll x = 0, b = 0;
for (ll i = 0; i < n; i += 3){
ll mask = 4 * a[i] + 2 * a[i + 1] + a[i + 2];
for (ll j = 0; j < (mp[mask].size()); j ++){
char c = mp[mask][j];
if (c == '1')
x += (1ll << b);
b++;
}
}
return x;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |