# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153078 | admin | Round words (IZhO13_rowords) | C++14 | 186 ms | 504 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>
#define get(arr, x) (((arr[x >> 6] >> (x & 63)) & 1) == 1)
#define set(arr, x) (arr[x >> 6] |= 1llu << (x & 63))
using ulint = unsigned long long;
int lcs(std::string A, std::string B) {
int N = A.size(), M = B.size();
int sz = (M >> 6) + 1;
std::vector<ulint> S[256];
for(int c = 0; c < 256; c++) S[c].resize(sz);
for(int j = 0; j < M; j++) set(S[B[j]], j);
std::vector<ulint> row(sz);
for(int j = 0; j < M; j++) if(A[0] == B[j]) { set(row, j); break; }
for(int i = 1; i < N; i++) {
ulint shl_carry = 1;
ulint minus_carry = 0;
for(int k = 0; k < sz; k++) {
// Compute k-th block of x == S[A[i]] OR M[i-1]
ulint x_k = S[A[i]][k] | row[k];
// Compute k-th block of "(M[i-1] << 1) | 1"
ulint term_1 = (row[k] << 1) | shl_carry;
shl_carry = row[k] >> 63;
// Compute k-th block of "x - ((M[i-1] << 1) | 1)"
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |