QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#344359 | #6527. Cyberland | Lavine | Compile Error | / | / | C++14 | 1.5kb | 2024-03-04 09:12:57 | 2024-03-04 09:12:57 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <assert.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
#ifdef _DEBUG
freopen("data.txt", "r", stdin);
#endif
cin.tie(0);
int T;
cin >> T;
while(T--) {
ll ans = 0;
int n;
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int num = 0;
for (int i = 0; i <= 61; i++) {
ll res = (1ll << i) - ans;
if (res + 1 > n) break;
num = i;
if (a[res] - a[res + 1] >= i) {
ans += (1ll << i);
}
}
// cout << ans << "!\n";
int flag = 1;
for (int i = 2; i <= n; i++) {
int now_cnt = __builtin_popcountll(ans + i - 1);
int pre_cnt = __builtin_popcountll(ans + i - 2);
if (now_cnt - pre_cnt != a[i] - a[i - 1]) {
flag = 0;
break;
}
}
int c = __builtin_popcountll(ans);
if (c > a[1]) flag = 0;
else {
for (int i = num + 1; i <= num + a[1] - c; i++) {
ans += (1ll << i);
}
}
if (flag) {
for (int i = 1; i <= n; i++) {
assert(__builtin_popcountll(ans + i - 1) == a[i]);
}
cout << ans << "\n";
} else {
cout << "-1\n";
}
}
}
Details
/usr/bin/ld: /tmp/ccJKKPFl.o: in function `main': answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/cctaBBGi.o:implementer.cpp:(.text.startup+0x0): first defined here /usr/bin/ld: /tmp/cctaBBGi.o: in function `main': implementer.cpp:(.text.startup+0x729): undefined reference to `solve(int, int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)' collect2: error: ld returned 1 exit status