# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1093582 |
2024-09-27T04:24:50 Z |
Luvidi |
Sličnost (COI23_slicnost) |
C++17 |
|
3000 ms |
3420 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
const int maxn=1e5;
int n,k,q,a[maxn],b[maxn],idx[maxn];
ll seg[maxn];
void upd(int i,int x){
i=idx[a[i]];
for(int j=max(0,i-(k-1));j<=min(i,n-k);j++){
seg[j]+=x;
}
}
void calc(){
memset(seg,0,sizeof(seg));
pll ans={0,0};
for(int i=0;i<k-1;i++){
upd(i,1);
}
for(int i=0;i<=n-k;i++){
upd(i+k-1,1);
for(int j=0;j<=n-k;j++){
if(seg[j]>ans.fs)ans={seg[j],1};
else if(seg[j]==ans.fs)ans.sc++;
}
upd(i,-1);
}
cout<<ans.fs<<' '<<ans.sc<<'\n';
}
void solve(){
cin>>n>>k>>q;
for(int i=0;i<n;i++){
cin>>a[i];
a[i]--;
}
for(int i=0;i<n;i++){
cin>>b[i];;
idx[--b[i]]=i;
}
calc();
while(q--){
int idx;
cin>>idx;
swap(a[idx],a[idx-1]);
calc();
}
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
0 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1116 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
1 ms |
1116 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
0 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1116 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
1 ms |
1116 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
16 |
Correct |
15 ms |
1248 KB |
Output is correct |
17 |
Correct |
14 ms |
1116 KB |
Output is correct |
18 |
Correct |
2 ms |
1116 KB |
Output is correct |
19 |
Correct |
10 ms |
1360 KB |
Output is correct |
20 |
Correct |
15 ms |
1116 KB |
Output is correct |
21 |
Correct |
14 ms |
1356 KB |
Output is correct |
22 |
Correct |
2 ms |
1360 KB |
Output is correct |
23 |
Correct |
15 ms |
1352 KB |
Output is correct |
24 |
Correct |
14 ms |
1112 KB |
Output is correct |
25 |
Correct |
15 ms |
1112 KB |
Output is correct |
26 |
Correct |
13 ms |
1368 KB |
Output is correct |
27 |
Correct |
14 ms |
1116 KB |
Output is correct |
28 |
Correct |
10 ms |
1116 KB |
Output is correct |
29 |
Correct |
8 ms |
1116 KB |
Output is correct |
30 |
Correct |
3 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
0 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1116 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
1 ms |
1116 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
16 |
Correct |
15 ms |
1248 KB |
Output is correct |
17 |
Correct |
14 ms |
1116 KB |
Output is correct |
18 |
Correct |
2 ms |
1116 KB |
Output is correct |
19 |
Correct |
10 ms |
1360 KB |
Output is correct |
20 |
Correct |
15 ms |
1116 KB |
Output is correct |
21 |
Correct |
14 ms |
1356 KB |
Output is correct |
22 |
Correct |
2 ms |
1360 KB |
Output is correct |
23 |
Correct |
15 ms |
1352 KB |
Output is correct |
24 |
Correct |
14 ms |
1112 KB |
Output is correct |
25 |
Correct |
15 ms |
1112 KB |
Output is correct |
26 |
Correct |
13 ms |
1368 KB |
Output is correct |
27 |
Correct |
14 ms |
1116 KB |
Output is correct |
28 |
Correct |
10 ms |
1116 KB |
Output is correct |
29 |
Correct |
8 ms |
1116 KB |
Output is correct |
30 |
Correct |
3 ms |
1116 KB |
Output is correct |
31 |
Execution timed out |
3069 ms |
3420 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
0 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1116 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
1 ms |
1116 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
16 |
Correct |
3 ms |
1116 KB |
Output is correct |
17 |
Correct |
3 ms |
1260 KB |
Output is correct |
18 |
Correct |
2 ms |
1112 KB |
Output is correct |
19 |
Correct |
3 ms |
1116 KB |
Output is correct |
20 |
Correct |
3 ms |
1260 KB |
Output is correct |
21 |
Correct |
2 ms |
1112 KB |
Output is correct |
22 |
Correct |
3 ms |
1116 KB |
Output is correct |
23 |
Correct |
3 ms |
1116 KB |
Output is correct |
24 |
Correct |
3 ms |
1116 KB |
Output is correct |
25 |
Correct |
3 ms |
1116 KB |
Output is correct |
26 |
Correct |
3 ms |
1116 KB |
Output is correct |
27 |
Correct |
3 ms |
1256 KB |
Output is correct |
28 |
Correct |
2 ms |
1216 KB |
Output is correct |
29 |
Correct |
3 ms |
1368 KB |
Output is correct |
30 |
Correct |
3 ms |
1252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
0 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1116 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
1 ms |
1116 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
16 |
Correct |
15 ms |
1248 KB |
Output is correct |
17 |
Correct |
14 ms |
1116 KB |
Output is correct |
18 |
Correct |
2 ms |
1116 KB |
Output is correct |
19 |
Correct |
10 ms |
1360 KB |
Output is correct |
20 |
Correct |
15 ms |
1116 KB |
Output is correct |
21 |
Correct |
14 ms |
1356 KB |
Output is correct |
22 |
Correct |
2 ms |
1360 KB |
Output is correct |
23 |
Correct |
15 ms |
1352 KB |
Output is correct |
24 |
Correct |
14 ms |
1112 KB |
Output is correct |
25 |
Correct |
15 ms |
1112 KB |
Output is correct |
26 |
Correct |
13 ms |
1368 KB |
Output is correct |
27 |
Correct |
14 ms |
1116 KB |
Output is correct |
28 |
Correct |
10 ms |
1116 KB |
Output is correct |
29 |
Correct |
8 ms |
1116 KB |
Output is correct |
30 |
Correct |
3 ms |
1116 KB |
Output is correct |
31 |
Correct |
3 ms |
1116 KB |
Output is correct |
32 |
Correct |
3 ms |
1260 KB |
Output is correct |
33 |
Correct |
2 ms |
1112 KB |
Output is correct |
34 |
Correct |
3 ms |
1116 KB |
Output is correct |
35 |
Correct |
3 ms |
1260 KB |
Output is correct |
36 |
Correct |
2 ms |
1112 KB |
Output is correct |
37 |
Correct |
3 ms |
1116 KB |
Output is correct |
38 |
Correct |
3 ms |
1116 KB |
Output is correct |
39 |
Correct |
3 ms |
1116 KB |
Output is correct |
40 |
Correct |
3 ms |
1116 KB |
Output is correct |
41 |
Correct |
3 ms |
1116 KB |
Output is correct |
42 |
Correct |
3 ms |
1256 KB |
Output is correct |
43 |
Correct |
2 ms |
1216 KB |
Output is correct |
44 |
Correct |
3 ms |
1368 KB |
Output is correct |
45 |
Correct |
3 ms |
1252 KB |
Output is correct |
46 |
Execution timed out |
3015 ms |
1372 KB |
Time limit exceeded |
47 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
0 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1116 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
1 ms |
1116 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
16 |
Correct |
15 ms |
1248 KB |
Output is correct |
17 |
Correct |
14 ms |
1116 KB |
Output is correct |
18 |
Correct |
2 ms |
1116 KB |
Output is correct |
19 |
Correct |
10 ms |
1360 KB |
Output is correct |
20 |
Correct |
15 ms |
1116 KB |
Output is correct |
21 |
Correct |
14 ms |
1356 KB |
Output is correct |
22 |
Correct |
2 ms |
1360 KB |
Output is correct |
23 |
Correct |
15 ms |
1352 KB |
Output is correct |
24 |
Correct |
14 ms |
1112 KB |
Output is correct |
25 |
Correct |
15 ms |
1112 KB |
Output is correct |
26 |
Correct |
13 ms |
1368 KB |
Output is correct |
27 |
Correct |
14 ms |
1116 KB |
Output is correct |
28 |
Correct |
10 ms |
1116 KB |
Output is correct |
29 |
Correct |
8 ms |
1116 KB |
Output is correct |
30 |
Correct |
3 ms |
1116 KB |
Output is correct |
31 |
Execution timed out |
3069 ms |
3420 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |