QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#81961 | #4860. Longest Common Subsequence | Sorting# | WA | 1544ms | 57560kb | C++14 | 898b | 2023-02-26 19:16:21 | 2023-02-26 19:16:39 |
Judging History
answer
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <math.h>
#include <numeric>
typedef long long ll;
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--){
ll n, m, p, x, a, b, c;
cin >> n >> m >> p >> x >> a >> b >> c;
vector<int> s(n), t(m);
map<int, int> first;
for(int i = 0; i < n; ++i){
x = (a * x * x + b * x + c) % p;
s[i] = x;
if(!first.count(x))
first[x] = i;
}
int ans = 0;
for(int i = 0; i < m; ++i){
x = (a * x * x + b * x + c) % p;
t[i] = x;
if(first.count(x)){
ans = max(ans, (int)min(m - i, n - first[x]));
}
}
cout << ans << "\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3276kb
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: 1544ms
memory: 57460kb
input:
1 1000000 1000000 999999937 0 0 11 1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 1357ms
memory: 57560kb
input:
1 1000000 1000000 1000000000 0 0 2 1
output:
437492
result:
ok 1 number(s): "437492"
Test #4:
score: 0
Accepted
time: 31ms
memory: 10812kb
input:
1 1000000 1000000 1000000000 0 0 0 0
output:
1000000
result:
ok 1 number(s): "1000000"
Test #5:
score: 0
Accepted
time: 3ms
memory: 3308kb
input:
1000 3 1 6 0 5 3 4 12 1 3 2 0 2 2 2 10 1 0 0 0 0 8 1 1 0 0 0 0 5 10 1 0 0 0 0 3 3 9 0 8 2 7 7 2 5 0 4 2 4 2 2 3 1 2 2 1 13 17 4 3 3 3 3 6 9 6 0 4 5 3 5 21 9 1 6 2 0 5 2 8 6 0 4 1 21 7 10 5 3 6 7 23 11 2 1 0 0 1 14 3 10 5 4 6 3 3 33 8 0 7 3 0 2 4 5 4 0 2 0 43 3 9 2 6 8 4 10 10 4 3 2 0 1 16 32 2 1 1 1...
output:
1 1 2 1 5 2 2 2 13 6 5 2 7 11 3 3 2 3 10 16 3 15 3 1 1 12 12 11 2 1 15 4 3 7 1 7 3 15 3 6 3 1 1 16 1 2 9 9 0 0 1 1 2 0 5 1 6 6 1 5 3 1 6 3 7 16 13 4 4 4 3 5 12 2 8 7 1 8 6 11 5 1 5 4 6 5 3 3 3 7 3 6 5 2 8 4 14 8 6 1 15 1 2 4 3 5 7 3 1 2 3 1 4 1 2 2 2 10 0 2 3 12 4 2 1 25 9 12 1 1 1 2 6 1 7 1 3 1 7 1...
result:
ok 1000 numbers
Test #6:
score: 0
Accepted
time: 3ms
memory: 3288kb
input:
1000 14 6 7 1 1 5 5 6 2 6 3 2 5 2 13 10 5 0 2 1 4 7 2 1 0 0 0 0 7 18 2 1 0 0 1 22 1 8 7 1 6 4 15 1 3 2 1 1 1 3 14 4 3 2 0 1 21 5 4 1 0 1 2 4 8 3 2 2 2 2 12 3 9 4 6 3 2 13 16 1 0 0 0 0 12 21 9 0 1 8 5 2 1 8 1 0 1 5 8 51 10 7 0 6 8 6 1 5 0 3 1 4 3 18 5 0 0 4 2 8 32 8 4 2 0 2 20 6 5 4 0 3 3 20 2 9 0 4 ...
output:
6 2 10 2 7 1 1 3 5 4 3 13 11 0 8 1 3 8 6 2 3 10 7 4 3 2 1 9 4 0 1 2 2 3 3 3 1 19 13 2 16 20 14 4 7 3 7 3 4 4 13 7 5 2 7 5 2 1 2 8 1 3 1 1 15 4 6 6 1 2 2 7 0 2 4 6 8 4 6 3 2 8 7 16 3 6 4 12 16 13 4 3 1 2 6 11 8 9 8 13 1 1 1 1 7 6 7 1 2 1 4 0 4 4 3 2 9 1 3 5 3 8 6 14 7 3 2 1 2 0 2 2 7 2 3 9 1 6 2 3 1 ...
result:
ok 1000 numbers
Test #7:
score: 0
Accepted
time: 3ms
memory: 3284kb
input:
1000 11 3 4 3 2 2 1 7 11 1 0 0 0 0 4 1 1 0 0 0 0 5 13 8 1 7 3 7 8 24 3 2 1 2 1 13 7 5 4 1 0 2 6 2 6 1 1 0 1 2 26 2 0 0 1 0 3 14 6 5 3 1 3 9 47 10 2 2 6 1 6 7 9 3 0 0 8 6 7 5 2 3 4 3 10 8 2 1 0 0 0 6 5 1 0 0 0 0 7 1 10 1 4 9 2 29 15 8 0 3 5 2 1 6 10 9 8 3 9 13 3 8 4 2 5 4 12 18 6 1 5 3 2 18 7 4 0 2 3...
output:
3 7 1 5 7 7 2 2 3 9 6 6 8 5 1 15 1 3 12 7 0 2 13 1 14 2 3 17 3 6 4 1 2 7 4 5 6 11 1 2 1 3 3 5 3 0 3 6 8 2 2 2 1 5 1 4 9 3 5 2 5 0 3 0 10 1 21 2 3 5 8 1 3 3 12 1 3 23 10 24 1 12 14 7 6 11 6 4 4 3 4 3 1 1 6 9 3 3 9 10 4 1 7 5 11 1 2 1 1 9 4 2 1 1 2 6 11 4 2 11 14 6 3 4 2 8 1 3 3 2 1 5 2 7 4 3 3 6 6 3 ...
result:
ok 1000 numbers
Test #8:
score: 0
Accepted
time: 2ms
memory: 3340kb
input:
1000 33 16 5 3 1 0 0 45 2 10 7 5 5 5 16 8 5 0 3 2 3 13 4 5 0 2 0 1 4 12 4 2 2 0 0 22 6 1 0 0 0 0 12 17 3 2 0 2 2 5 1 1 0 0 0 0 12 12 10 3 7 9 2 2 1 7 3 2 3 5 5 1 7 1 4 3 6 1 6 10 1 9 3 9 16 2 3 2 0 2 2 5 1 4 0 3 2 2 12 7 4 0 2 0 0 2 21 4 0 1 3 1 1 3 1 0 0 0 0 11 3 3 1 0 2 0 2 23 5 2 3 0 3 3 1 8 2 1 ...
output:
16 2 8 4 4 6 12 1 12 0 1 1 2 1 7 2 1 3 2 1 1 1 9 3 3 6 4 1 6 10 2 1 7 3 1 4 1 2 1 1 6 9 7 9 3 3 1 1 9 5 4 3 3 1 1 1 2 7 4 5 1 10 14 3 2 4 3 12 1 4 5 0 3 8 1 7 5 2 7 6 6 11 1 5 4 7 1 7 5 4 4 6 2 6 11 9 8 0 4 2 7 1 2 7 1 3 2 3 3 13 4 3 12 12 1 1 2 2 2 18 22 1 3 9 1 14 2 1 9 1 3 6 5 2 8 1 1 9 6 1 1 4 7...
result:
ok 1000 numbers
Test #9:
score: 0
Accepted
time: 1ms
memory: 3276kb
input:
1000 5 9 6 5 1 2 1 15 7 5 4 4 3 1 6 22 8 5 6 0 1 10 41 1 0 0 0 0 3 8 1 0 0 0 0 3 10 5 0 4 1 4 8 25 10 2 1 6 8 10 4 7 4 5 4 0 12 25 1 0 0 0 0 10 1 3 2 1 1 2 13 8 8 7 2 2 3 16 7 7 0 1 2 5 19 1 1 0 0 0 0 30 3 9 5 6 5 5 3 7 5 0 4 1 2 3 7 1 0 0 0 0 1 2 6 0 2 3 0 4 4 4 0 1 0 1 2 3 4 2 3 2 3 1 1 4 3 2 3 3 ...
output:
4 7 6 10 3 2 7 4 12 1 8 7 1 3 3 3 1 4 2 0 2 8 3 1 2 6 7 3 5 3 1 9 12 7 2 7 1 10 8 3 4 3 6 3 12 6 10 3 1 4 3 3 4 3 4 5 15 2 1 4 5 2 3 2 12 6 1 0 2 0 3 2 2 3 10 2 2 3 2 3 7 2 1 1 2 1 7 2 3 3 3 2 4 1 3 2 9 5 3 15 4 10 3 4 4 5 1 5 6 1 2 7 7 1 4 11 1 7 4 2 3 10 5 5 1 4 2 9 1 7 3 1 10 6 1 1 2 18 16 1 2 11...
result:
ok 1000 numbers
Test #10:
score: 0
Accepted
time: 3ms
memory: 3336kb
input:
1000 7 14 4 1 2 1 3 4 2 9 7 4 1 8 10 1 5 2 0 4 0 10 3 4 2 0 0 3 4 10 3 2 0 2 1 5 2 9 6 6 8 0 9 13 2 0 0 0 0 10 2 6 0 1 0 2 1 1 9 3 2 4 2 26 14 4 0 2 0 3 8 39 6 5 3 3 5 5 29 1 0 0 0 0 7 6 5 0 2 2 1 6 6 8 3 1 7 2 2 14 6 0 5 3 1 1 6 7 1 6 1 6 5 1 9 8 3 2 0 1 8 4 2 0 0 2 17 10 8 6 1 7 4 4 7 7 0 5 3 5 4 ...
output:
7 2 1 3 4 2 9 2 0 14 8 5 6 4 2 1 0 1 10 4 4 3 3 6 1 8 10 1 4 12 9 4 3 4 2 5 2 13 7 13 5 6 5 1 9 1 1 4 2 1 19 23 5 6 9 6 8 7 3 6 2 4 1 2 1 3 2 15 4 14 7 7 3 3 3 2 2 8 1 2 3 17 2 14 9 1 3 9 1 2 8 3 1 6 14 1 3 8 13 9 2 3 4 3 7 9 18 3 2 2 25 0 1 4 1 5 2 1 1 2 21 10 2 7 2 8 4 9 2 4 1 5 17 2 5 2 1 2 1 19 ...
result:
ok 1000 numbers
Test #11:
score: -100
Wrong Answer
time: 4ms
memory: 3292kb
input:
1000 11 17 364842564 82604785 37722477 127540201 348362558 1 9 901635804 270985425 297435912 869439619 220374725 2 1 37302871 5111534 30668704 32082155 31325822 3 4 99577587 77936588 43641803 21097237 21318455 8 5 712082931 351941911 501914122 261694155 309605826 14 6 651864103 92791431 550378703 26...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 289th numbers differ - expected: '17', found: '0'