QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#55316#4860. Longest Common Subsequencezhoukangyang#WA 1662ms58432kbC++111019b2022-10-13 08:07:582022-10-13 08:07:59

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-13 08:07:59]
  • 评测
  • 测评结果:WA
  • 用时:1662ms
  • 内存:58432kb
  • [2022-10-13 08:07:58]
  • 提交

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;
}

详细

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'