# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1077177 | veehj | Broken Device (JOI17_broken_device) | C++17 | 1 ms | 1208 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |