# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
657390 | bicsi | Necklace (Subtask 4) (BOI19_necklace4) | C++14 | 151 ms | 628 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
const ld EPS = 1e-8;
int main() {
string s, t; cin >> s >> t;
mt19937_64 rng(52);
vector<complex<ld>> rnd(256);
for (int i = 0; i < 256; ++i) {
ld real = 1.0L * rng() / rng.max();
ld imag = 1.0L * rng() / rng.max();
rnd[i] = {real, imag};
}
vector<pair<ld, int>> vs, vt;
auto check = [&](int len) {
complex<ld> eps = polar(1.0L, 2.0L * M_PI / len);
pair<int, int> ans = {-1, -1};
for (int rev = 0; rev < 2; ++rev) {
vs.clear(); vt.clear();
for (int it = 0; it < 2; ++it) {
complex<ld> h = 0;
for (int i = 0; i < (int)s.size(); ++i) {
h = (h + rnd[s[i]]) * eps;
if (i >= len - 1) {
vs.emplace_back(abs(h), i - len + 1);
h -= rnd[s[i - len + 1]];
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |