QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#514787#7845. Fast ForwardUmokCompile Error//C++141.5kb2024-08-11 10:42:072024-08-11 10:42:07

Judging History

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

  • [2024-08-11 10:42:07]
  • 评测
  • [2024-08-11 10:42:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define uint unsigned long long
#define lb(x) (x & (-x))
#define endl '\n'
#define INF LONG_LONG_MAX
#define eps 1e-7
const int N = 2e6 + 5;
typedef pair<int, int> PII;

int ar[N], pre[N], len = 21;
int st[3e6+2][25];
void solve()
{
    int n, m;
    cin >> n >> m;
    len = log(n) / log(2) + 1;
    for (int i = 1; i <= n; i++)
        cin >> ar[i], ar[i + n] = ar[i];
    for (int i = 1; i <= 2 * n; i++)
        pre[i] = pre[i - 1] + ar[i];

    for (int i = 0; i <= len; i++)
        st[2 * n + 1][i] = INF;

    for (int i = 1; i <= 2 * n; i++)
    {
        int l = i - 1, r = 2 * n;
        while (l + 1 < r)
        {
            int mid = (l + r) >> 1;
            if (pre[mid] - pre[i - 1] >= m)
                r = mid;
            else
                l = mid;
        }
        st[i][0] = r + 1;
    }

    for (int j = 1; j <= len; j++)
        for (int i = 1; i <= 2 * n; i++)
            st[i][j] = st[st[i][j - 1]][j - 1];

    for (int i = 1; i <= n; i++)
    {
        int ans = 0;
        int t = i;
        for (int j = len - 1; j >= 0; j--)
        {
            if (st[t][j] < i + n)
            {

                t = st[t][j];
                ans += 1 << j;
            }
        }
        cout << ans << " ";
    }
}
signed main()
{
    IOS;
    solve();
    return 0;
}

详细

answer.code:14:11: error: conversion from ‘double’ to ‘long unsigned int’ in a converted constant expression
   14 | int st[3e6+2][25];
      |        ~~~^~
answer.code:14:11: error: could not convert ‘(3.0e+6 + (double)2)’ from ‘double’ to ‘long unsigned int’
   14 | int st[3e6+2][25];
      |        ~~~^~
      |           |
      |           double
answer.code:14:11: error: size of array ‘st’ has non-integral type ‘double’