Submission #991262

#TimeUsernameProblemLanguageResultExecution timeMemory
991262onbertBroken Device (JOI17_broken_device)C++17
85 / 100
30 ms3096 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; #define int long long const int m = 37; void Anna(int32_t n, long long x, int32_t k, int32_t p[]){ int pwr[m+1]; pwr[0] = 1; for (int i=1;i<=m;i++) pwr[i] = pwr[i-1] * 3; int a[n]; for (int i=0;i<n;i++) a[i] = 1; for (int i=0;i<k;i++) a[p[i]] = 0; for (int i=0;i<n;i++) if (a[i ^ 1]==0) a[i] = 0; int cur = 0; for (int i=0;i<n;i+=2) if (a[i]) { int val = x%3; if (val==0) a[i] = 0, a[i+1] = 1; if (val==1) a[i] = 1, a[i+1] = 0; x /= 3; } // for (int i=0;i<n;i++) cout << a[i]; cout << endl; for (int i=0;i<n;i++) Set(i, (int32_t)a[i]); }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; #define int long long const int m = 37; long long Bruno(int32_t n, int32_t a[]){ int pwr[m+1]; pwr[0] = 1; for (int i=1;i<=m;i++) pwr[i] = pwr[i-1] * 3; int x = 0; int cur = 0; for (int i=0;i<n && cur<=m;i+=2) if (a[i]==1 || a[i+1]==1) { if (a[i]==1 && a[i+1]==0) x += pwr[cur]; if (a[i]==1 && a[i+1]==1) x += 2*pwr[cur]; cur++; } // cout << x << endl; return x; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int32_t, long long int, int32_t, int32_t*)':
Anna.cpp:15:9: warning: unused variable 'cur' [-Wunused-variable]
   15 |     int cur = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...