QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#631277 | #21648. Runs | pskkk | Compile Error | / | / | C++23 | 3.1kb | 2024-10-11 23:40:53 | 2024-10-11 23:40:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
struct Runs {
int l, r, p;
bool operator==(const Runs &j) {
return l == j.l && r == j.r && p == j.p;
}
};
const int mod = 998244353, mod1 = 1e9 + 7, mod2 = 1e9 + 9;
const int bas1 = 315, bas2 = 79;
const int maxn = 2e6 + 5;
char t[maxn];
int m;
namespace getRuns {
struct Hash {
long long p[maxn], h[maxn];
int mod, buf;
Hash(int _buf, int _mod) {
buf = _buf;
mod = _mod;
}
void Init(char *s, int n) {
p[0] = 1;
h[0] = 0;
for (int i = 1; i <= n; i++) {
p[i] = p[i - 1] * buf % mod;
h[i] = (h[i - 1] * buf + s[i] - 'a' + 1) % mod;
}
}
bool tl(int u, int v, int len) {
return (h[u] - h[v] + (h[v - len] - h[u - len]) * p[len]) % mod == 0;
}
bool tr(int u, int v, int len) {
return (h[u + len - 1] - h[v + len - 1] + (h[v - 1] - h[u - 1]) * p[len]) % mod == 0;
}
int get(int l, int r) {
return (h[r] + (mod - h[l - 1]) * p[r - l + 1] % mod) % mod;
}
} h1(bas1, mod1), h2(bas2, mod2);
int extr(int x, int y) {
int l = 0, r = m - max(x, y) + 1, res = 0;
while (l <= r) {
int mid = l + r >> 1;
if (h1.tr(x, y, mid) && h2.tr(x, y, mid)) {
res = mid;
l = mid + 1;
} else
r = mid - 1;
}
return res;
}
int extl(int x, int y) {
int l = 0, r = min(x, y), res = 0;
while (l <= r) {
int mid = l + r >> 1;
if (h1.tl(x, y, mid) && h2.tl(x, y, mid)) {
res = mid;
l = mid + 1;
} else
r = mid - 1;
}
return res;
}
vector<Runs> raw_runs(0);
int CMP(int x, int y) {
if (x == y)
return 0;
int l = extr(x, y);
return t[x + l] < t[y + l] ? -1 : 1;
}
void Check(int i, int j) {
int p = j - i + 1;
int x = i - extl(i - 1, j), y = j + extr(i, j + 1);
if (y - x + 1 >= p * 2)
raw_runs.push_back({x, y, p});
}
int st[maxn], top;
void init() {
for (int i = m; i; i--) {
while (top && CMP(i, st[top]) <= 0)
top--;
if (top)
Check(i, st[top] - 1);
st[++top] = i;
}
top = 0;
for (int i = m; i; i--) {
while (top && CMP(i, st[top]) >= 0)
top--;
if (top)
Check(i, st[top] - 1);
st[++top] = i;
}
}
} // namespace getRuns
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> (t + 1);
m = strlen(t + 1);
getRuns::h1.Init(t, m);
getRuns::h2.Init(t, m);
getRuns::init();
sort(getRuns::raw_runs.begin(), getRuns::raw_runs.end(), [](const Runs & A, const Runs & B) {
return A.l == B.l ? (A.r == B.r ? A.p < B.p : A.r < B.r) : A.l < B.l;
});
int tot = std::unique(getRuns::raw_runs.begin(), getRuns::raw_runs.end()) - getRuns::raw_runs.begin();
cout << tot << '\n';
getRuns::raw_runs.resize(tot);
for (auto [l, r, p] : getRuns::raw_runs)
cout << l << " " << r << " " << p << '\n';
}
Details
answer.code: In function ‘int main()’: answer.code:116:9: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’) 116 | cin >> (t + 1); | ~~~ ^~ ~~~~~~~ | | | | | char* | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/13/sstream:40, from /usr/include/c++/13/complex:45, from /usr/include/c++/13/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127, from answer.code:1: /usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 325 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/13/istream:325:7: note: conversion of argument 1 would be ill-formed: answer.code:116:15: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’ 116 | cin >> (t + 1); | ~~~^~~~ /usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 201 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:201:7: note: conversion of argument 1 would be ill-formed: answer.code:116:15: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive] 116 | cin >> (t + 1); | ~~~^~~~ | | | char* answer.code:116:15: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& t)) + 1)’ to ‘long long unsigned int&’ /usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 197 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:197:7: note: conversion of argument 1 would be ill-formed: answer.code:116:15: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive] 116 | cin >> (t + 1); | ~~~^~~~ | | | char* answer.code:116:15: error: cannot bind rvalue ‘(long long int)(((char*)(& t)) + 1)’ to ‘long long int&’ /usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:192:7: note: conversion of argument 1 would be ill-formed: answer.code:116:15: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive] 116 | cin >> (t + 1); | ~~~^~~~ | | | char* answer.code:116:15: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& t)) + 1)’ to ‘long unsigned int&’ /usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:188:7: note: conversion of argument 1 would be ill-formed: answer.code:116:15: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive] 116 | cin >> (t + 1); | ~~~^~~~ | | | char* answer.code:116:15: error: cannot bind rvalue ‘(long int)(((char*)(& t)) + 1)’ to ‘long int&’ /usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/13/istream:184:7: note: conversion of argument 1 would be ill-formed: answer.code:116:15: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive] 116 | cin >> (t + 1); | ~~~^~~~ | | | char* answer.code:116:15: error: cannot bind rvalue ‘(unsigned int)(((char*)(& t)) + 1)’ to ‘unsigned int&’ /usr/include/c++/13/istream:181:7: note: candidate: ‘std::basic_...