Submission #1077181

#TimeUsernameProblemLanguageResultExecution timeMemory
1077181veehjBroken Device (JOI17_broken_device)C++17
0 / 100
2 ms1056 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; void findans(ll x){ if(x%2) st.push(1); else st.push(0); x/=2; if(x!=0) findans(x); } void stop(ll till){ while(pl!=till+1){ Set(pl, 0); pl++; } } void Anna( int N, long long X, int K, int P[] ){ curr=0, pl=0; st={}; findans(X); if(st.size()%2) st.push(1); else st.push(0); while(pl!=N){ if(curr==K){ while(1){ if(st.empty()){ 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+3>P[curr]){ stop(P[curr]); curr++; break; } if(st.empty()){ 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(); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...