| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1235443 | chaeryeong | Broken Device (JOI17_broken_device) | C++20 | 20 ms | 1592 KiB | 
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Anna (int N, ll X, int K, int P[]) {
  const int B = 60;
  vector <int> bad(N, 0);
  for (int i = 0; i < K; i++) {
    bad[P[i]] = 1;
  }
/*  for (auto i : bad) {
    cout << i << " ";
  }
  cout << '\n';
  cout << '\n';
  for (int i = 0; i < B; i++) {
    cout << (X >> i) % 2 << " ";
  }
  cout << '\n';*/
  int b = 0;
  vector <int> ret(N, 0);
  for (int i = 0; i < B; i++) {
    //cout << i << ": " << b << '\n';
    if (!((X >> i) & 1)) {
      b++; continue;
    }
    int cnt = 0;
    bool flag = 0;
    for (int j = b; j < N; j++) {
      if (bad[j]) {
        cnt++;
      } else {
        if (j == N - 1) {
          if (cnt == 0) {
            ret[j] = 1;
            flag = 1;
            b = N;
            break;
          }
          break;
        }
        if (bad[j + 1]) {
          if (cnt == 0) {
            ret[j] = 1;
            flag = 1;
            b = j + 2;
            break;
          }
          cnt += 2;
          j++;
        } else {
          if (cnt) {
            ret[j] = ret[j + 1] = 1;
            cnt--;
            int k = j + 1;
            while (cnt && k + 1 < N && !bad[k + 1]) {
              k++; ret[k] = 1; cnt--;
            }
            j = k + 1;
          } else {
            ret[j] = 1; ret[j + 1] = 0;
            b = j + 2;
            flag = 1; break;
          }
        }
      }
    }
    if (!flag) {
      break;
    }
  }
/*  for (auto i : ret) {
    cout << i << " ";
  }
  cout << '\n';
  cout << '\n';
  for (int i = 0; i < B; i++) {
    cout << (X >> i) % 2 << " ";
  }
  cout << '\n';
  cout << '\n';
  for (auto i : bad) {
    cout << i << " ";
  }
  cout << '\n';*/
  for (int i = 0; i < N; i++) {
    Set(i, ret[i]);
  }
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll Bruno (int N, int A[]) {
  const int B = 60;
  vector <int> bits;
  ll ret = 0;
  for (int i = 0; i < N; i++) {
    if (A[i]) {
      if (i == N - 1) {
        bits.push_back(1);
      } else if (A[i + 1]) {
        bits.pop_back(); 
        int k = i + 1;
        while (k + 1 < N && A[k + 1]) {
          bits.pop_back(); k++;
        }
        i = k + 1;
      } else {
        bits.push_back(1); i++;
      }
    } else {
      bits.push_back(0);
    }
/*    cout << i << ": ";
    for (auto j : bits) {
      cout << j << " ";
    }
    cout << '\n';*/
  }
  for (int i = 0; i < (int)bits.size(); i++) {
    if (bits[i]) {
      ret += (1ll << i);
    }
  }
  return ret;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
