#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define F first
#define S second
#define sz(x) int(x.size())
const int MAX=1e5+5;
int n, k, q;
int a[MAX], b[MAX], ib[MAX];
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> k >> q;
for(int i=1; i<=n; i++) {
cin >> a[i];
}
for(int i=1; i<=n; i++) {
cin >> b[i];
ib[b[i]]=i;
}
vector<int> out(n+5);
for(int i=1; i+k-1<=n; i++) {
for(int j=1; j+k-1<=n; j++) {
int cnt=0;
for(int ii=i; ii<=i+k-1; ii++) {
if(ib[a[ii]]>=j && ib[a[ii]]<=j+k-1) {
cnt++;
}
}
out[cnt]++;
// if(cnt==1) {
// cout << i << ' ' << j << '\n';
// }
}
}
for(int i=n; i>=0; i--) {
if(out[i]>0) {
cout << i << ' ' << out[i] << '\n';
break;
}
}
while(q--) {
int t;
cin >> t;
swap(a[t], a[t+1]);
for(int i=0; i<n+5; i++) {
out[i]=0;
}
for(int i=1; i+k-1<=n; i++) {
for(int j=1; j+k-1<=n; j++) {
int cnt=0;
for(int ii=i; ii<=i+k-1; ii++) {
if(ib[a[ii]]>=j && ib[a[ii]]<=j+k-1) {
cnt++;
}
}
out[cnt]++;
// if(cnt==1) {
// cout << i << ' ' << j << '\n';
// }
}
}
for(int i=n; i>=0; i--) {
if(out[i]>0) {
cout << i << ' ' << out[i] << '\n';
break;
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |