# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1174955 | ortsac | Broken Device (JOI17_broken_device) | C++20 | 19 ms | 1564 KiB |
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
void Anna(int32_t n, int x, int32_t k, int32_t p[]) {
vector<int> ans(n);
vector<int> broken(n);
for (int i = 0; i < k; i++) broken[p[i]] = 1;
vector<int> pow7(22);
pow7[0] = 1;
for (int i = 1; i < 22; i++) pow7[i] = (7 * pow7[i - 1]);
int curr = 0;
for (int i = 21; i >= 0; i--) {
while (broken[curr] || broken[curr + 1] || broken[curr + 2]) curr += 3;
int qtd = 1;
while (x >= pow7[i]) {
qtd++;
x -= pow7[i];
}
//cout << qtd << "\n";
int b0 = (qtd % 2);
qtd /= 2;
int b1 = (qtd % 2);
qtd /= 2;
int b2 = (qtd % 2);
ans[curr] = b0;
ans[curr + 1] = b1;
ans[curr + 2] = b2;
curr += 3;
}
for (int i = 0; i < n; i++) {
Set(i, ans[i]);
//cout << ans[i] << " ";
}
//cout << "\n";
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
int Bruno(int32_t n, int32_t a[] ) {
int curr = 21;
vector<int> pow7(22);
pow7[0] = 1;
int ans = 0;
for (int i = 1; i < 22; i++) pow7[i] = (7 * pow7[i - 1]);
for (int i = 0; i < n; i += 3) {
if (a[i] | a[i + 1] | a[i + 2]) {
int qtd = -1;
qtd += (a[i]);
qtd += (2*a[i + 1]);
qtd += (4*a[i + 2]);
ans += (qtd * pow7[curr]);
curr--;
}
}
//cout << ans << "\n";
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |