QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#344359#6527. CyberlandLavineCompile Error//C++141.5kb2024-03-04 09:12:572024-03-04 09:12:57

Judging History

你现在查看的是最新测评结果

  • [2024-03-04 09:12:57]
  • 评测
  • [2024-03-04 09:12:57]
  • 提交

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";
        }
    }
}

详细

/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