Submission #61195

#TimeUsernameProblemLanguageResultExecution timeMemory
61195youngyojunBroken Device (JOI17_broken_device)C++11
100 / 100
88 ms3968 KiB
#include "Annalib.h" #include <bits/stdc++.h> #define pb push_back #define eb emplace_back #define allv(V) ((V).begin()),((V).end()) #define sorv(V) sort(allv(V)) #define univ(V) (V).erase(unique(allv(V)),(V).end()) #define revv(V) reverse(allv(V)) #define sz(V) ((int)(V).size()) #define upmin(a,b) (a)=min((a),(b)) #define upmax(a,b) (a)=max((a),(b)) #define rb(x) ((x)&(-(x))) #define INF (0x3f3f3f3f) #define INFLL (0x3f3f3f3f3f3f3f3fll) using namespace std; typedef long long ll; typedef pair<int, int> pii; static int A[160], B[66]; void Anna(int N, ll X, int K, int P[]) { fill(A, A+N+1, 1); for(int i = 0; i < K; i++) A[P[i]] = 0; for(int i = 0; i < 60; i++) B[i] = !!(X & (1ll<<i)); for(int i = 0, j = 0; i < N && j < 60; i += 3) { if(A[i] + A[i+1] + A[i+2] < 2) { A[i] = A[i+1] = A[i+2] = 0; continue; } if(B[j] && B[j+1]) { // 11 if(A[i] && A[i+1] && A[i+2]) { j += 2; continue; } if(A[i+1]) A[i] = A[i+2] = 0; j++; } else if(B[j]) { // 10 if(A[i+1] && A[i+2]) { A[i] = 0; j += 2; continue; } if(A[i+1]) A[i] = A[i+2] = 0; j++; } else if(!B[j] && B[j+1]) { // 01 if(A[i]) { A[i+1] = A[i+2] = 0; j += 2; continue; } A[i] = A[i+1] = 0; j++; } else { // 00 if(A[i] && A[i+1]) { A[i+2] = 0; j += 2; continue; } A[i] = A[i+1] = 0; j++; } } for(int i = 0; i < N; i++) Set(i, !!A[i]); }
#include "Brunolib.h" #include <bits/stdc++.h> #define pb push_back #define eb emplace_back #define allv(V) ((V).begin()),((V).end()) #define sorv(V) sort(allv(V)) #define univ(V) (V).erase(unique(allv(V)),(V).end()) #define revv(V) reverse(allv(V)) #define sz(V) ((int)(V).size()) #define upmin(a,b) (a)=min((a),(b)) #define upmax(a,b) (a)=max((a),(b)) #define rb(x) ((x)&(-(x))) #define INF (0x3f3f3f3f) #define INFLL (0x3f3f3f3f3f3f3f3fll) using namespace std; typedef long long ll; typedef pair<int, int> pii; ll Bruno(int N, int A[]) { vector<int> V; for(int i = 0; i < N; i += 3) if(A[i] || A[i+1] || A[i+2]) { int t = (A[i]<<2) | (A[i+1]<<1) | A[i+2]; if(1 == t) V.eb(0); else if(2 == t) V.eb(1); else if(3 == t) { V.eb(1); V.eb(0); } else if(4 == t) { V.eb(0); V.eb(1); } else if(5 == t) V.eb(1); else if(6 == t) { V.eb(0); V.eb(0); } else { V.eb(1); V.eb(1); } } ll ret = 0; for(int j = 60; j--;) ret = (ret << 1) | V[j]; return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...