답안 #1077239

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077239 2024-08-27T03:49:05 Z veehj Broken Device (JOI17_broken_device) C++17
0 / 100
33 ms 3032 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 3032 KB Program terminated incorrectly, or you printed something to stdout
2 Incorrect 24 ms 2736 KB Program terminated incorrectly, or you printed something to stdout
3 Incorrect 23 ms 2756 KB Program terminated incorrectly, or you printed something to stdout
4 Incorrect 25 ms 2732 KB Program terminated incorrectly, or you printed something to stdout
5 Incorrect 23 ms 2936 KB Program terminated incorrectly, or you printed something to stdout
6 Incorrect 23 ms 2820 KB Program terminated incorrectly, or you printed something to stdout
7 Incorrect 26 ms 2664 KB Program terminated incorrectly, or you printed something to stdout
8 Incorrect 23 ms 2756 KB Program terminated incorrectly, or you printed something to stdout
9 Incorrect 28 ms 2760 KB Program terminated incorrectly, or you printed something to stdout
10 Incorrect 24 ms 2764 KB Program terminated incorrectly, or you printed something to stdout
11 Incorrect 22 ms 2784 KB Program terminated incorrectly, or you printed something to stdout
12 Incorrect 22 ms 2760 KB Program terminated incorrectly, or you printed something to stdout
13 Incorrect 23 ms 2760 KB Program terminated incorrectly, or you printed something to stdout
14 Incorrect 23 ms 2752 KB Program terminated incorrectly, or you printed something to stdout
15 Incorrect 24 ms 2756 KB Program terminated incorrectly, or you printed something to stdout
16 Incorrect 23 ms 2756 KB Program terminated incorrectly, or you printed something to stdout
17 Incorrect 26 ms 2912 KB Program terminated incorrectly, or you printed something to stdout
18 Incorrect 23 ms 2824 KB Program terminated incorrectly, or you printed something to stdout
19 Incorrect 27 ms 2828 KB Program terminated incorrectly, or you printed something to stdout
20 Incorrect 25 ms 2720 KB Program terminated incorrectly, or you printed something to stdout
21 Incorrect 28 ms 2692 KB Program terminated incorrectly, or you printed something to stdout
22 Incorrect 22 ms 2764 KB Program terminated incorrectly, or you printed something to stdout
23 Incorrect 23 ms 2756 KB Program terminated incorrectly, or you printed something to stdout
24 Incorrect 24 ms 2780 KB Program terminated incorrectly, or you printed something to stdout
25 Incorrect 23 ms 2772 KB Program terminated incorrectly, or you printed something to stdout
26 Incorrect 25 ms 2668 KB Program terminated incorrectly, or you printed something to stdout
27 Incorrect 24 ms 2704 KB Program terminated incorrectly, or you printed something to stdout
28 Incorrect 30 ms 2732 KB Program terminated incorrectly, or you printed something to stdout
29 Incorrect 23 ms 2756 KB Program terminated incorrectly, or you printed something to stdout
30 Incorrect 24 ms 2756 KB Program terminated incorrectly, or you printed something to stdout
31 Incorrect 26 ms 2732 KB Program terminated incorrectly, or you printed something to stdout
32 Incorrect 28 ms 2732 KB Program terminated incorrectly, or you printed something to stdout
33 Incorrect 28 ms 2784 KB Program terminated incorrectly, or you printed something to stdout
34 Incorrect 24 ms 2852 KB Program terminated incorrectly, or you printed something to stdout
35 Incorrect 23 ms 2852 KB Program terminated incorrectly, or you printed something to stdout
36 Incorrect 24 ms 2756 KB Program terminated incorrectly, or you printed something to stdout
37 Incorrect 24 ms 2868 KB Program terminated incorrectly, or you printed something to stdout
38 Incorrect 33 ms 2852 KB Program terminated incorrectly, or you printed something to stdout
39 Incorrect 25 ms 2756 KB Program terminated incorrectly, or you printed something to stdout
40 Incorrect 24 ms 2672 KB Program terminated incorrectly, or you printed something to stdout