Submission #1077239

#TimeUsernameProblemLanguageResultExecution timeMemory
1077239veehjBroken Device (JOI17_broken_device)C++17
0 / 100
33 ms3032 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define F first #define S second #define pb push_back #define sz(a) (ll) a.size() #define all(x) (x).begin(), (x).end() stack<ll> st; int pl, curr, cnt=0, n; void findans(ll x){ if(x%2) st.push(1); else st.push(0); x/=2; if(x!=0) findans(x); } void stop(int till){ while(pl<=min(till, n-1)){ Set(pl, 0); pl++; } } void Anna( int N, long long X, int K, int P[] ){ curr=0, pl=0; st={}; n=N; findans(X); if(st.size()%2) st.push(1); else st.push(0); while(pl<N){ if(curr==K){ while(1){ if(st.empty() || pl+2>n-1){ stop(N-1); return; } Set(pl, 1); pl++; Set(pl, st.top()); pl++; st.pop(); if(st.empty()){ stop(N-1); return; } Set(pl, st.top()); pl++; st.pop(); if(st.empty()){ stop(N-1); return; } } } else { if(pl==P[curr]){ Set(pl, 0); pl++; curr++; continue; } while(1){ if(pl+2>=P[curr]){ stop(P[curr]); curr++; break; } if(st.empty() || pl+2>n-1){ stop(N-1); return; } Set(pl, 1); pl++; Set(pl, st.top()); pl++; st.pop(); if(st.empty()){ stop(N-1); return; } Set(pl, st.top()); pl++; st.pop(); if(st.empty()){ stop(N-1); return; } } } } }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define F first #define S second #define pb push_back #define sz(a) (ll) a.size() #define all(x) (x).begin(), (x).end() queue<int> q; int ok=0; ll ans=0; long long Bruno( int N, int A[] ){ q={}; for(int i=0; i<N; i++){ if(A[i]==1){ i++; if(q.empty()) ok=A[i]; else q.push(A[i]); i++; q.push(A[i]); } } while(!q.empty()){ if(q.size()==1 && !ok) break; ans*=2; ans+=q.front(); q.pop(); } cout << ans << endl; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...