제출 #1319770

#제출 시각아이디문제언어결과실행 시간메모리
1319770PlayVoltzBroken Device (JOI17_broken_device)C++20
100 / 100
19 ms1560 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second void Anna(int n, long long x, int k, int p[]){ vector<bool> die(n, 0), res(n, 0); for (int i=0; i<k; ++i)die[p[i]]=1; long long b=0; for (int i=0; i<n/3&&b<60; ++i){ if (b==59){ if ((1ll<<b)&x&&!die[i+2*n/3])res[i+2*n/3]=1, ++b; else if (!((1ll<<b)&x)&&!die[i+n/3])res[i+n/3]=1, ++b; else if ((1ll<<b)&x&&!die[i]&&!die[i+n/3])res[i]=res[i+n/3]=1, ++b; continue; } bool done=0; if (((1ll<<b)&x)&&((1ll<<(b+1))&x)){ if (!die[i]&&!die[i+n/3]&&!die[i+2*n/3])res[i]=res[i+n/3]=res[i+2*n/3]=1, b+=2, done=1; } else if (!((1ll<<b)&x)&&!((1ll<<(b+1))&x)){ if (!die[i])res[i]=1, b+=2, done=1; } else if (((1ll<<b)&x)&&!((1ll<<(b+1))&x)){ if (!die[i+n/3]&&!die[i+2*n/3])res[i+n/3]=res[i+2*n/3]=1, b+=2, done=1; } else if (!((1ll<<b)&x)&&((1ll<<(b+1))&x)){ if (!die[i]&&!die[i+2*n/3])res[i]=res[i+2*n/3]=1, b+=2, done=1; } if (!done){ if ((1ll<<b)&x&&!die[i+2*n/3])res[i+2*n/3]=1, ++b; else if (!((1ll<<b)&x)&&!die[i+n/3])res[i+n/3]=1, ++b; else if ((1ll<<b)&x&&!die[i]&&!die[i+n/3])res[i]=res[i+n/3]=1, ++b; } } for (int i=0; i<n; ++i)Set(i, res[i]); }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second long long Bruno(int n, int vect[]){ long long res=0, b=0; for (int i=0; i<n/3&&b<60; ++i){ if (!vect[i]&&!vect[i+n/3]&&!vect[i+2*n/3])continue; if (!vect[i]&&!vect[i+n/3]&&vect[i+2*n/3])res+=(1ll<<b), ++b; if (!vect[i]&&vect[i+n/3]&&!vect[i+2*n/3])++b; if (!vect[i]&&vect[i+n/3]&&vect[i+2*n/3])res+=(1ll<<b), b+=2; if (vect[i]&&!vect[i+n/3]&&!vect[i+2*n/3])b+=2; if (vect[i]&&!vect[i+n/3]&&vect[i+2*n/3])res+=(1ll<<(b+1)), b+=2; if (vect[i]&&vect[i+n/3]&&!vect[i+2*n/3])res+=(1ll<<b), ++b; if (vect[i]&&vect[i+n/3]&&vect[i+2*n/3])res+=(1ll<<b)+(1ll<<(b+1)), b+=2; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...