QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#55316 | #4860. Longest Common Subsequence | zhoukangyang# | WA | 1662ms | 58432kb | C++11 | 1019b | 2022-10-13 08:07:58 | 2022-10-13 08:07:59 |
Judging History
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define vi vector < int >
#define me(a, x) memset(a, x, sizeof(a))
#define ull unsigned long long
#define ld __float128
using namespace std;
const int N = 2e6 + 7;
int n, m, s[N], t[N];
int mod, x, a, b, c;
map < int, int > mp;
void Main() {
cin >> n >> m;
cin >> mod >> x >> a >> b >> c;
L(i, 1, n) {
x = (((ll) x * a + b) % mod * x + c) % mod, s[i] = x;
}
L(i, 1, m) {
x = (((ll) x * a + b) % mod * x + c) % mod, t[i] = x;
}
// L(i, 1, n) {
// cout << s[i] << ' ';
// }
// cout << '\n';
mp.clear();
R(i, n, 1) {
mp[s[i]] = i;
}
int ns = 0;
L(i, 1, m) {
if(mp.count(t[i])) {
ns = max(ns, n - min(i, mp[t[i]]) + 1);
}
}
cout << ns << '\n';
}
int main() {
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t;
cin >> t;
while(t--) Main();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3640kb
input:
2 4 3 1024 1 1 1 1 3 4 1024 0 0 0 0
output:
0 3
result:
ok 2 number(s): "0 3"
Test #2:
score: 0
Accepted
time: 1662ms
memory: 58332kb
input:
1 1000000 1000000 999999937 0 0 11 1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 1455ms
memory: 58432kb
input:
1 1000000 1000000 1000000000 0 0 2 1
output:
999992
result:
wrong answer 1st numbers differ - expected: '437492', found: '999992'