QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#81959 | #4860. Longest Common Subsequence | Sorting# | WA | 1488ms | 57600kb | C++14 | 907b | 2023-02-26 19:15:01 | 2023-02-26 19:15:05 |
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 = min(m - i, n - first[x]);
break;
}
}
cout << ans << "\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3280kb
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: 1488ms
memory: 57580kb
input:
1 1000000 1000000 999999937 0 0 11 1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 1002ms
memory: 57600kb
input:
1 1000000 1000000 1000000000 0 0 2 1
output:
437492
result:
ok 1 number(s): "437492"
Test #4:
score: 0
Accepted
time: 18ms
memory: 10848kb
input:
1 1000000 1000000 1000000000 0 0 0 0
output:
1000000
result:
ok 1 number(s): "1000000"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3288kb
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 2 15 3 1 1 12 12 11 2 1 15 4 2 7 1 7 2 15 2 6 3 1 1 16 1 2 9 9 0 0 1 1 2 0 5 1 6 6 1 5 3 1 6 2 7 16 13 4 4 4 3 5 12 2 8 7 1 8 6 11 4 1 5 4 6 5 2 3 3 7 3 6 4 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:
wrong answer 21st numbers differ - expected: '3', found: '2'