# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
596897 | jy0n | Round words (IZhO13_rowords) | C++17 | 100 ms | 308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
const int Sigma= 26;
string A, B;
vector<ull> d, s[Sigma];
#define set_bit(bs, i) (bs[i>>6] |= 1llu << (i&63))
#define get_bit(bs, i) ((bs[i>>6] >> (i&63))&1)
#define sub(a, b) ((a-b>a)? (a-=b, 1) : (a-=b, 0))
int main() {
cin >> A >> B;
int n = (int)A.size(), m = (int)B.size(), l = (m>>6)+1, ans=0;
d.resize(l);
for (int i=0; i<Sigma; ++i) s[i].resize(l);
for (int i=0; i<m; ++i) set_bit(s[B[i]-'a'], i);
for (int k=0; k<n; ++k) {
memset(&d[0], 0, sizeof(ull)*l);
for (int i=0; i<m; ++i) if (A[k] == B[i]) { set_bit(d, i); break; }
for (int i=1; i<n; ++i) {
ull sc = 1, mc = 0;
for (int j=0; j<l; ++j) {
ull x = s[A[(k+i)%n]-'a'][j]|d[j];
ull t = (d[j] << 1)|sc;
sc = d[j] >> 63;
ull tt = x;
mc = sub(tt, mc) + sub(tt, t);
d[j] = x&(x^tt);
}
}
int ret = 0;
for (int i=0; i<m; ++i) ret += get_bit(d, i);
ans=max(ans, ret);
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |