# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1219993 | vako_p | Broken Device (JOI17_broken_device) | C++20 | 24 ms | 1580 KiB |
#include<bits/stdc++.h>
using namespace std;
#include "Annalib.h"
#define ll long long
void f(ll i, string s){
for(auto it : s){
int x = it - '0';
Set(i, x);
i++;
}
}
void Anna( int N, long long X, int K, int P[] ){
ll n = N,x = X,bit = 0,vis[N];
for(int i = 0; i < n; i++) vis[i] = 1;
for(int i = 0; i < K; i++) vis[P[i]] = 0;
map<string,string> mp;
mp["00"] = "011";
mp["01"] = "010";
mp["10"] = "101";
mp["11"] = "111";
for(int i = 0; i < n; i += 3){
if(vis[i] + vis[i + 1] + vis[i + 2] >= 2 and bit < 60){
if((!vis[i] and !((1LL << bit) & x)) or vis[i] + vis[i + 1] + vis[i + 2] == 3){
ll ok = (((1LL << bit) & x) > 0);
char ch = '0' + ok;
string s = "";
s += ch;
bit++;
ok = (((1LL << bit) & x) > 0);
ch = (ok + '0');
s += ch;
bit++;
// cout << i << ' ' << s << '\n';
f(i, mp[s]);
}
else{
if((1LL << bit) & x){
if(!vis[i + 2]) f(i, "110");
else f(i, "001");
}
else f(i, "100");
bit++;
}
}
else f(i, "000");
}
// cout << "--> " << bit << endl;
}
#include "Brunolib.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ff(ll &bit, string s){
// cout << s;
ll res = 0;
for(auto it : s){
if(it == '1'){
res += (1LL << bit);
// cout << "aaaaaa" << bit << endl;
}
bit++;
}
return res;
}
long long Bruno(int N, int A[]){
ll res = 0;
ll n = N,bit = 0;
map<string,string> mp;
mp["000"] = "";
mp["100"] = "0";
mp["110"] = "1";
mp["001"] = "1";
mp["011"] = "00";
mp["010"] = "01";
mp["101"] = "10";
mp["111"] = "11";
for(int i = 0; i < n; i += 3){
string s = "";
s += (A[i] + '0');
s += (A[i + 1] + '0');
s += (A[i + 2] + '0');
res += ff(bit, mp[s]);
}
// cout << res << endl;
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |