QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#564847 | #7859. Bladestorm | 1234567890# | Compile Error | / | / | C++14 | 2.8kb | 2024-09-15 15:35:44 | 2024-09-15 15:35:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define inf (ll)1e9
#define pii pair <ll, ll>
#define fr first
#define se second
const ll mod = 1e9 + 7;
char buf[1 << 21], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 18, stdin), p1 == p2) ? EOF : *p1++)
inline ll read() {
ll x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9') f = ((ch == '-') ? -1 : f), ch = getchar();
while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
return x * f;
}
inline void write(ll x) {
if(x < 0) x = -x, putchar('-');
if(x >= 10) write(x / 10);
putchar(x % 10 + '0');
}
inline ll quickmod(ll x, ll y) {
ll Ans = 1;
while(y) {
if(y & 1) Ans = (1ll * Ans * x) % mod;
x = (1ll * x * x) % mod;
y >>= 1;
}
return Ans;
}
inline void Add(ll &x, ll y) {
x += y;
if(x >= mod) x -= mod;
}
inline void Dec(ll &x, ll y) {
x -= y;
if(x < 0) x += mod;
}
inline ll add(ll x, ll y) {
x += y;
if(x >= mod) x -= mod;
return x;
}
inline ll dec(ll x, ll y) {
x -= y;
if(x < 0) x += mod;
return x;
}
ll n, k;
struct Block {
ll M = 500, mx;
ll L[1005], R[1005], pos[100005], cnt;
ll nxt[100005], val[100005], num[100005], suf[100005];
bool vis[100005];
inline void init() {
mx = 0;
M = max(3ll, sqrt(n));
for(ll i = 1; i <= n; i++) {
pos[i] = i / M + 1;
if(!L[pos[i]]) L[pos[i]] = i;
R[pos[i]] = i;
cnt = pos[i];
}
for(ll i = 0; i <= n; i++) nxt[i] = val[i] = suf[i] = 0, vis[i] = 0;
for(ll i = 1; i <= cnt; i++) num[i] = 0;
}
inline ll findnxt(ll p) {
for(ll i = p; i <= cnt; i++) if(num[i]) for(ll j = L[i]; j <= R[i]; j++) if(vis[j]) return j;
return -1;
}
inline void insert(ll ins) {
ll p = pos[ins];
mx = max(mx, ins);
vis[ins] = 1, num[p]++;
ll Nxt = 0;
for(ll i = R[p]; i >= L[p]; i--) {
nxt[i] = val[i] = 0;
if(i == R[p]) suf[i] = vis[i];
else suf[i] = suf[i+1] + vis[i];
if(Nxt > i + k) nxt[i] = (nxt[Nxt] ? nxt[Nxt] : Nxt), val[i] = val[Nxt] + 1;
else {
if(i + k <= R[p] && Nxt) nxt[i] = i + k, val[i] = 1;
}
if(vis[i]) Nxt = i;
}
}
inline void get_ans() {
ll Ans = 0, now = 0;
while(now < mx) {
if(nxt[now]) Ans += val[now], now = nxt[now];
else {
if(now != R[pos[now]] && suf[now+1]) now += k, Ans++;
else {
ll Nxt = findnxt(pos[now] + 1);
now = max(now + k, Nxt), Ans++;
}
}
}
write(Ans), putchar(' ');
}
}B;
int main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ll T = read();
while(T--) {
n = read(), k = read();
B.init();
for(ll i = 1; i <= n; i++) B.insert(read()), B.get_ans();
putchar('\n');
}
return 0;
}
/*
1
9 2
1 2 3 7 8 9 4 5 6
*/
Details
answer.code: In member function ‘void Block::init()’: answer.code:59:24: error: no matching function for call to ‘max(long long int, __gnu_cxx::__enable_if<true, double>::__type)’ 59 | M = max(3ll, sqrt(n)); | ~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: answer.code:59:24: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘__gnu_cxx::__enable_if<true, double>::__type’ {aka ‘double’}) 59 | M = max(3ll, sqrt(n)); | ~~~^~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed: answer.code:59:24: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘__gnu_cxx::__enable_if<true, double>::__type’ {aka ‘double’}) 59 | M = max(3ll, sqrt(n)); | ~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:61: /usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’ 5795 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed: answer.code:59:24: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 59 | M = max(3ll, sqrt(n)); | ~~~^~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’ 5805 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed: answer.code:59:24: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 59 | M = max(3ll, sqrt(n)); | ~~~^~~~~~~~~~~~~~