# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
549360 | Lobo | Broken Device (JOI17_broken_device) | C++17 | 50 ms | 2700 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 "Annalib.h"
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = 280;
void Anna(int32_t N, int X, int32_t K, int32_t P[]) {
int mark[N+10];
int n = N;
for(int i = 0; i < n; i++) {
mark[i] = 0;
}
for(int i = 0; i < K; i++) {
int p = P[i];
mark[p] = 1;
if(p%2 == 0) {
mark[p+1] = 1;
}
else {
mark[p-1] = 1;
}
}
string s;
//escreve X aqui
for(int i = 0; i < 60; i+= 3) {
int a = ((X&(1LL<<i)) != 0);
int b = ((X&(1LL<<(i+1))) != 0);
int c = ((X&(1LL<<(i+2))) != 0);
string s1;
if(a == 0 && b == 0 && c == 0) {
s1 = "1010";
}
else if(a == 1 && b == 0 && c == 0) {
s1 = "1011";
}
else {
if(a == 0) s1+= '0';
else s1+= '1';
s1+= '1';
if(b == 0) s1+= '0';
else s1+= '1';
if(c == 0) s1+= '0';
else s1+= '1';
}
s+= s1;
}
string ans;
int id = 0;
for(int i = 0; i < n; i++) {
if(mark[i] || id == s.size()) {
ans+= '0';
}
else {
ans+= s[id++];
}
}
for(int i = 0; i < n; i++) {
if(ans[i] == '0') Set(i,0);
else Set(i,1);
}
}
// int32_t main() {
// ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
// // freopen("out.out", "w", stdout);
// int32_t N,X,K;
// cin >> N >> X >> K;
// int32_t P[K];
// for(int i = 0; i < K; i++) {
// cin >> P[i];
// }
// Anna(N,X,K,P);
// }
#include "Brunolib.h"
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = -1;
int Bruno(int32_t N, int32_t A[]) {
int n = N;
string s;
for(int i = 0; i < n; i+=2) {
if(A[i] == 0 && A[i+1] == 0) {
continue;
}
s+= (char) A[i]+'0';
s+= (char) A[i+1]+'0';
}
int x = 0;
for(int i = 0, pt = 0; i < s.size(); pt+= 3, i+= 4) {
string s1;
s1+= s[i];
s1+= s[i+1];
s1+= s[i+2];
s1+= s[i+3];
int a,b,c;
if(s1 == "1010") {
a = 0;
b = 0;
c = 0;
}
else if(s1 == "1011") {
a = 1;
b = 0;
c = 0;
}
else {
if(s1[0] == '0') a = 0;
else a = 1;
if(s1[2] == '0') b = 0;
else b = 1;
if(s1[3] == '0') c = 0;
else c = 1;
}
x+= a*(1LL<<pt);
x+= b*(1LL<<(pt+1));
x+= c*(1LL<<(pt+2));
}
return x;
}
// int32_t main() {
// ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
// // freopen("out.out", "w", stdout);
// int32_t N; cin >> N;
// int32_t A[N];
// string s; cin >> s;
// for(int i = 0; i < N; i++) {
// if(s[i] == '0') A[i] = 0;
// else A[i] = 1;
// }
// cout << Bruno(N,A) << endl;
// }
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |