Submission #70023

#TimeUsernameProblemLanguageResultExecution timeMemory
70023TalantBroken Device (JOI17_broken_device)C++17
41 / 100
76 ms6656 KiB
#include "Annalib.h"

#include <bits/stdc++.h>

#define sc second
#define fr first
#define pb push_back
#define mk make_pair

using namespace std;

string bin(long long x) {
      string a = "";
      while(x) {
            a += (char)(x % 2 + '0');
            x /= 2;
      }
      return a;
}
int u[200];
int ind;

void Anna( int n, long long x, int k, int p[] ){
      string s = bin(x);
      memset(u,0,sizeof(u));
      ind = 0;

      for (int i = 0; i < k; i ++)
            u[p[i]] = 1;

      for (int i = 0; i < n; i ++) {
            if (ind >= (int)s.size()) {
                  Set(i,0);
                  continue;
            }
            if (i + 1 < n && u[i] + u[i + 1] < 1) {
                  Set(i,1);
                  Set(i + 1,(int)(s[ind] - '0'));
                  ind ++;
                  i ++;
            }
            else {
                  Set(i,0);
            }
      }
}
#include "Brunolib.h"

#include <bits/stdc++.h>

#define sc second
#define fr first
#define pb push_back
#define mk make_pair

using namespace std;

long long ans;
long long cnt;

long long Bruno( int N, int a[] ){
      ans = 0;
      cnt = 0;

      for (int i = 0; i < N - 1; i ++) {
            if (a[i] == 1) {
                  ans += (1ll << cnt) * 1ll *  a[i + 1];
                  cnt ++;
                  i ++;
            }
      }
      return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...