Submission #1209184

#TimeUsernameProblemLanguageResultExecution timeMemory
1209184mychecksedadBroken Device (JOI17_broken_device)C++20
100 / 100
22 ms1556 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> #include "Annalib.h" using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30; void Anna( int n, long long X, int k, int p[] ){ vector<int> good(n, 1); for(int i = 0; i < k; ++i) good[p[i]] = 0; vi bits; while(X){ bits.pb(X%2); X /= 2; } for(int j = 0; j < 60; ++j) bits.pb(0); int ptr = 0; for(int i = 2; i < n; i += 3){ int bad = 3 - good[i] - good[i - 1] - good[i - 2]; if(bad >= 2){ Set(i, 0); Set(i-1, 0); Set(i-2, 0); }else{ if(bad == 0){ int num = bits[ptr++] * 2; num += bits[ptr++]; if(num == 0){ Set(i, 1); Set(i-1, 0); Set(i-2, 1); }else if(num == 1){ Set(i, 1); Set(i-1, 1); Set(i-2, 1); }else if(num == 2){ Set(i, 0); Set(i-1, 1); Set(i-2, 0); }else{ Set(i, 1); Set(i-1, 1); Set(i-2, 0); } }else{ int val = bits[ptr++]; if(good[i] == 0){ if(val == 0){ Set(i, 0); Set(i-1, 1); Set(i-2, 1); }else{ Set(i, 0); Set(i-1, 0); Set(i-2, 1); } }else if(good[i - 1] == 0){ if(val == 0){ Set(i, 1); Set(i-1, 0); Set(i-2, 0); }else{ Set(i, 0); Set(i-1, 0); Set(i-2, 1); } }else{ if(val == 0){ Set(i, 1); Set(i-1, 0); Set(i-2, 0); }else{ int nxt = bits[ptr++]; if(nxt==0){ Set(i, 0); Set(i-1, 1); Set(i-2, 0); }else{ Set(i, 1); Set(i-1, 1); Set(i-2, 0); } } } } } } }
#include<bits/stdc++.h> #include "Brunolib.h" using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30; long long Bruno( int n, int a[] ){ ll ans = 0; vi v; map<string, vi> m; m["001"] = vi{0}; m["100"] = vi{1}; m["110"] = vi{0}; m["010"] = vi{1, 0}; m["011"] = vi{1, 1}; m["101"] = vi{0, 0}; m["111"] = vi{0, 1}; for(int i = 2; i < n; i += 3){ string t; t += char(a[i - 2] + '0'); t += char(a[i - 1] + '0'); t += char(a[i] + '0'); if(t != "000"){ for(int j: m[t]) v.pb(j); } } reverse(all(v)); for(int b: v){ ans *= 2; ans += b; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...