QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#418333#8416. Dzielniki [B]helhyCompile Error//C++141.7kb2024-05-23 12:50:532024-05-23 12:50:53

Judging History

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

  • [2024-05-23 12:50:53]
  • 评测
  • [2024-05-23 12:50:53]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;
const long long N = 2e5 + 5;

int ID;
int n;
long long a[N];
bool check_same()
{
    for (int i = 2; i <= n; i++)
        if (a[i] != a[i - 1])
            return false;
    return true;
}
bool check_diff()
{
    static long long b[N];
    memcpy(b, a, sizeof(a));
    sort(b + 1, b + n + 1);
    for (int i = 2; i <= n; i++)
        if (a[i] == a[i - 1])
            return false;
    return true;
}

void init(int _n, const vector<long long> &_a)
{
    n = _n;
    for (int i = 1; i <= n; i++) a[i] = _a[i - 1];
    if (check_same())
        ID = 1;
    else if (check_diff())
        ID = 2;
    else if (n <= 1000)
        ID = 3;
    else
        ID = 4;
}

long long ask(int l, int r) { return 0; }

long long solve1(int l, int r) { return a[l] + (r - l + 1); }
long long solve3(int l, int r)
{
    static map<long long, int> cnt;
    cnt.clear();
    long long power = 1, id = 0;
    for (int i = l; i <= r; i++)
    {
        cnt[a[i]]++;
        while (power * 2 < a[i])
        {
            power *= 2;
            id++;
        }
    }
    cnt.insert({ power, 0 });
    long long sum = 0, maxd = 0;
    for (auto it = ++cnt.find(power); it != cnt.end(); it++)
    {
        sum += it->second;
        maxd = max(maxd, sum - it->first + power);
    }
    return power + sum + r - l + 1 - maxd;
}

vector<long long> askAll(int q, const vector<int> &l, const vector<int> &r)
{
    vector<long long> ans(q);
    for (int i = 0; i < q; i++)
    {
        ans[i] = a[1] + (r[i] - l[i] + 1);
    }
    return ans;
}

详细

implementer.cpp: In function ‘long long int Ask(long long int)’:
implementer.cpp:254:18: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  254 |         for(auto [x,y]:mp) res=res*(y+1);
      |                  ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status