QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#416698 | #149. Peru | Amigoo | Compile Error | / | / | C++20 | 2.2kb | 2024-05-22 03:25:02 | 2024-09-10 16:46:02 |
Judging History
你现在查看的是最新测评结果
- [2024-09-10 16:46:02]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-05-22 03:25:02]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-05-22 03:25:02]
- 提交
answer
#include <bits/stdc++.h>
#include "peru.h"
using namespace std;
const long long MOD = 1e9 + 7;
// const long long MOD = 998244353;
const long long OO = 1e10, N = 1e5 + 5, LOG = 20;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define popCnt(x) (__builtin_popcountll(x))
#define int long long
#define ll long long
#define F first
#define S second
#define double long double
#define pi M_PI
#define all(x) x.begin() , x.end()
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
void add (int val, int idx, deque<pair<int, int>> &d)
{
while(!d.empty() && d.front().first <= val)d.pop_front();
d.push_front({val, idx});
}
void del(int idx, deque<pair<int, int>> &d)
{
if(!d.empty() && d.back().second == idx)d.pop_back();
}
int power(long long x, unsigned int y)
{
long long p = MOD;
int res = 1;
x = x % p;
if (x == 0) return 0;
while (y > 0)
{
if (y & 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
int add(int a, int b)
{
return ((a % MOD) + (b % MOD)) % MOD;
}
int mul(int a, int b)
{
return ((a % MOD) * (b % MOD)) % MOD;
}
int solve(int N, int K, int *S)
{
deque<pair<int, int>>d;
int ans[N] = {};
for (int i = 0; i < K; ++i)
{
add(S[i], i, d);
ans[i] = d.back().first;
}
for (int i = K; i < N; ++i)
{
del(i - K, d);
add(S[i], i, d);
ans[i] = d.back().first + ans[i - K];
}
int x = 0;
for (int i = 0; i < N; ++i)
{
x = add(x, mul(ans[i], power(23, N - i - 1)));
}
return x;
}
signed main()
{
fast;
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("Output.txt", "w", stdout);
// #endif
int t = 1;
// cin >> t;
for (int tct = 1; tct <= t; tct++)
{
int n ;
cin >> n;
int k;
cin >> k;
int a[n];
for (int i = 0; i < n; ++i)
{
cin >> a[i];
}
cout << solve(n, k, a) << endl;
}
}
Details
implementer.cpp: In function ‘char nextch()’: implementer.cpp:15:31: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | if (pos == BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos = 0; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccUcAXeF.o: in function `main': answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccsE01AE.o:implementer.cpp:(.text.startup+0x0): first defined here /usr/bin/ld: /tmp/ccsE01AE.o: in function `main': implementer.cpp:(.text.startup+0x151): undefined reference to `solve(int, int, int*)' collect2: error: ld returned 1 exit status