# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
926052 |
2024-02-12T13:50:51 Z |
Amr |
Sličnost (COI23_slicnost) |
C++14 |
|
84 ms |
17236 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define S second
#define F first
#define all(x) (x).begin(),(x).end()
#define sz size()
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define pb(x) push_back(x);
#define endl '\n'
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N=6e5+7;
ll INF=INT_MAX,mod=1e9+7;
int TT=1;
ll power(ll x, unsigned int y)
{
ll res = 1;
x = x; // % mod;
if (x == 0) return 0;
while (y > 0)
{
if (y & 1) res = (res*x) ; // % mod;
y = y>>1;
x = (x*x) ; // % mod;
}
return res;
}
int siz = 1;
pair<int,int> val[N];
int L[N];
int R[N];
int a[N];
int b[N];
int n , k , q;
int s[N];
int pro[N];
void build(ll x, ll lx, ll rx)
{
if(rx-lx==1)
{
pro[x] = 0;
val[x] = {0,1};
return;
}
ll mid = (lx+rx)/2;
build(2*x+1,lx,mid);
build(2*x+2,mid,rx);
val[x].S = val[2*x+1].S + val[2*x+2].S;
val[x].F = 0;
}
void rebuild()
{
while(siz<=n) siz*=2;
build(0,0,siz);
for(int i = 1; i <= n; i++) s[i] = 0;
}
void update(ll l , ll r, ll num , ll x = 0, ll lx = 0, ll rx = siz)
{
if(lx>=r||rx<=l) return;
//
if(rx-lx>1)
{
val[2*x+1].F+=pro[x];
val[2*x+2].F+=pro[x];
pro[2*x+1] += pro[x];
pro[2*x+2] += pro[x];
pro[x] = 0;
}
if(lx>=l&&rx<=r)
{
val[x].F +=num;
pro[x] +=num;
return;
}
ll mid = (lx+rx)/2;
update(l,r,num,2*x+1,lx,mid);
update(l,r,num,2*x+2,mid,rx);
if(val[2*x+1].F==val[2*x+2].F) val[x] = {val[2*x+1].F,val[2*x+2].S+val[2*x+1].S};
else val[x] = max(val[2*x+1],val[2*x+2]);
//pro[x] = pro[2*x+1]+pro[2*x+2];
}
pair<ll,ll> get()
{
int mx = 0;
rebuild();
for(int i = 1; i < k; i++)
{
//cout << L[a[i]] << " " << R[a[i]] << endl;
update(L[a[i]],R[a[i]]+1,1);
}
//update(1,siz);
//return {val[0].F, val[0].S};
for(int i = k; i <= n;i++)
{
if(i-k>0) update(L[a[i-k]],R[a[i-k]]+1,-1);
update(L[a[i]],R[a[i]]+1,1);
s[val[0].F]+=val[0].S;
//cout << val[0].F << " " << val[0].S << endl;
mx=max(mx,val[0].F);
}
return {mx,s[mx]};
}
void solve()
{
cin >> n >> k >> q;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n;i++) cin >> b[i];
for(int i = 1; i <= n; i++)
{
L[b[i]] = max(1,i-k+1);
R[b[i]] = min(i,n-k+1);
//cout << L[b[i]] << " " << R[b[i]] << endl;
}
pair<int,int> p = get();
cout << p.F << " " << p.S << endl;
while(q--)
{
int x; cin >> x;
swap(a[x],a[x+1]);
pair<int,int> p = get();
cout << p.F << " " << p.S << endl;;
}
}
int main(){
//freopen("friday.in","r",stdin);
//freopen("friday.out","w",stdout);
fast;
while(TT--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12636 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12888 KB |
Output is correct |
4 |
Correct |
1 ms |
12636 KB |
Output is correct |
5 |
Correct |
2 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12636 KB |
Output is correct |
8 |
Correct |
2 ms |
12632 KB |
Output is correct |
9 |
Correct |
2 ms |
12636 KB |
Output is correct |
10 |
Correct |
2 ms |
12636 KB |
Output is correct |
11 |
Correct |
2 ms |
12636 KB |
Output is correct |
12 |
Correct |
2 ms |
12636 KB |
Output is correct |
13 |
Correct |
2 ms |
12636 KB |
Output is correct |
14 |
Correct |
3 ms |
12636 KB |
Output is correct |
15 |
Correct |
2 ms |
12636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12636 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12888 KB |
Output is correct |
4 |
Correct |
1 ms |
12636 KB |
Output is correct |
5 |
Correct |
2 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12636 KB |
Output is correct |
8 |
Correct |
2 ms |
12632 KB |
Output is correct |
9 |
Correct |
2 ms |
12636 KB |
Output is correct |
10 |
Correct |
2 ms |
12636 KB |
Output is correct |
11 |
Correct |
2 ms |
12636 KB |
Output is correct |
12 |
Correct |
2 ms |
12636 KB |
Output is correct |
13 |
Correct |
2 ms |
12636 KB |
Output is correct |
14 |
Correct |
3 ms |
12636 KB |
Output is correct |
15 |
Correct |
2 ms |
12636 KB |
Output is correct |
16 |
Correct |
3 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12772 KB |
Output is correct |
18 |
Correct |
4 ms |
12888 KB |
Output is correct |
19 |
Correct |
4 ms |
12780 KB |
Output is correct |
20 |
Correct |
5 ms |
12636 KB |
Output is correct |
21 |
Correct |
4 ms |
12636 KB |
Output is correct |
22 |
Correct |
3 ms |
12636 KB |
Output is correct |
23 |
Correct |
5 ms |
12636 KB |
Output is correct |
24 |
Correct |
4 ms |
12636 KB |
Output is correct |
25 |
Correct |
4 ms |
12836 KB |
Output is correct |
26 |
Correct |
5 ms |
12636 KB |
Output is correct |
27 |
Correct |
5 ms |
12636 KB |
Output is correct |
28 |
Correct |
4 ms |
12636 KB |
Output is correct |
29 |
Correct |
4 ms |
12636 KB |
Output is correct |
30 |
Correct |
3 ms |
12636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12636 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12888 KB |
Output is correct |
4 |
Correct |
1 ms |
12636 KB |
Output is correct |
5 |
Correct |
2 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12636 KB |
Output is correct |
8 |
Correct |
2 ms |
12632 KB |
Output is correct |
9 |
Correct |
2 ms |
12636 KB |
Output is correct |
10 |
Correct |
2 ms |
12636 KB |
Output is correct |
11 |
Correct |
2 ms |
12636 KB |
Output is correct |
12 |
Correct |
2 ms |
12636 KB |
Output is correct |
13 |
Correct |
2 ms |
12636 KB |
Output is correct |
14 |
Correct |
3 ms |
12636 KB |
Output is correct |
15 |
Correct |
2 ms |
12636 KB |
Output is correct |
16 |
Correct |
3 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12772 KB |
Output is correct |
18 |
Correct |
4 ms |
12888 KB |
Output is correct |
19 |
Correct |
4 ms |
12780 KB |
Output is correct |
20 |
Correct |
5 ms |
12636 KB |
Output is correct |
21 |
Correct |
4 ms |
12636 KB |
Output is correct |
22 |
Correct |
3 ms |
12636 KB |
Output is correct |
23 |
Correct |
5 ms |
12636 KB |
Output is correct |
24 |
Correct |
4 ms |
12636 KB |
Output is correct |
25 |
Correct |
4 ms |
12836 KB |
Output is correct |
26 |
Correct |
5 ms |
12636 KB |
Output is correct |
27 |
Correct |
5 ms |
12636 KB |
Output is correct |
28 |
Correct |
4 ms |
12636 KB |
Output is correct |
29 |
Correct |
4 ms |
12636 KB |
Output is correct |
30 |
Correct |
3 ms |
12636 KB |
Output is correct |
31 |
Correct |
49 ms |
16988 KB |
Output is correct |
32 |
Correct |
56 ms |
17236 KB |
Output is correct |
33 |
Correct |
29 ms |
16732 KB |
Output is correct |
34 |
Correct |
68 ms |
16976 KB |
Output is correct |
35 |
Correct |
84 ms |
16988 KB |
Output is correct |
36 |
Correct |
73 ms |
16980 KB |
Output is correct |
37 |
Correct |
42 ms |
16732 KB |
Output is correct |
38 |
Correct |
82 ms |
17016 KB |
Output is correct |
39 |
Incorrect |
65 ms |
16988 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12636 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12888 KB |
Output is correct |
4 |
Correct |
1 ms |
12636 KB |
Output is correct |
5 |
Correct |
2 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12636 KB |
Output is correct |
8 |
Correct |
2 ms |
12632 KB |
Output is correct |
9 |
Correct |
2 ms |
12636 KB |
Output is correct |
10 |
Correct |
2 ms |
12636 KB |
Output is correct |
11 |
Correct |
2 ms |
12636 KB |
Output is correct |
12 |
Correct |
2 ms |
12636 KB |
Output is correct |
13 |
Correct |
2 ms |
12636 KB |
Output is correct |
14 |
Correct |
3 ms |
12636 KB |
Output is correct |
15 |
Correct |
2 ms |
12636 KB |
Output is correct |
16 |
Correct |
3 ms |
12632 KB |
Output is correct |
17 |
Incorrect |
3 ms |
12636 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12636 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12888 KB |
Output is correct |
4 |
Correct |
1 ms |
12636 KB |
Output is correct |
5 |
Correct |
2 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12636 KB |
Output is correct |
8 |
Correct |
2 ms |
12632 KB |
Output is correct |
9 |
Correct |
2 ms |
12636 KB |
Output is correct |
10 |
Correct |
2 ms |
12636 KB |
Output is correct |
11 |
Correct |
2 ms |
12636 KB |
Output is correct |
12 |
Correct |
2 ms |
12636 KB |
Output is correct |
13 |
Correct |
2 ms |
12636 KB |
Output is correct |
14 |
Correct |
3 ms |
12636 KB |
Output is correct |
15 |
Correct |
2 ms |
12636 KB |
Output is correct |
16 |
Correct |
3 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12772 KB |
Output is correct |
18 |
Correct |
4 ms |
12888 KB |
Output is correct |
19 |
Correct |
4 ms |
12780 KB |
Output is correct |
20 |
Correct |
5 ms |
12636 KB |
Output is correct |
21 |
Correct |
4 ms |
12636 KB |
Output is correct |
22 |
Correct |
3 ms |
12636 KB |
Output is correct |
23 |
Correct |
5 ms |
12636 KB |
Output is correct |
24 |
Correct |
4 ms |
12636 KB |
Output is correct |
25 |
Correct |
4 ms |
12836 KB |
Output is correct |
26 |
Correct |
5 ms |
12636 KB |
Output is correct |
27 |
Correct |
5 ms |
12636 KB |
Output is correct |
28 |
Correct |
4 ms |
12636 KB |
Output is correct |
29 |
Correct |
4 ms |
12636 KB |
Output is correct |
30 |
Correct |
3 ms |
12636 KB |
Output is correct |
31 |
Correct |
3 ms |
12632 KB |
Output is correct |
32 |
Incorrect |
3 ms |
12636 KB |
Output isn't correct |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12636 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12888 KB |
Output is correct |
4 |
Correct |
1 ms |
12636 KB |
Output is correct |
5 |
Correct |
2 ms |
12636 KB |
Output is correct |
6 |
Correct |
2 ms |
12636 KB |
Output is correct |
7 |
Correct |
2 ms |
12636 KB |
Output is correct |
8 |
Correct |
2 ms |
12632 KB |
Output is correct |
9 |
Correct |
2 ms |
12636 KB |
Output is correct |
10 |
Correct |
2 ms |
12636 KB |
Output is correct |
11 |
Correct |
2 ms |
12636 KB |
Output is correct |
12 |
Correct |
2 ms |
12636 KB |
Output is correct |
13 |
Correct |
2 ms |
12636 KB |
Output is correct |
14 |
Correct |
3 ms |
12636 KB |
Output is correct |
15 |
Correct |
2 ms |
12636 KB |
Output is correct |
16 |
Correct |
3 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12772 KB |
Output is correct |
18 |
Correct |
4 ms |
12888 KB |
Output is correct |
19 |
Correct |
4 ms |
12780 KB |
Output is correct |
20 |
Correct |
5 ms |
12636 KB |
Output is correct |
21 |
Correct |
4 ms |
12636 KB |
Output is correct |
22 |
Correct |
3 ms |
12636 KB |
Output is correct |
23 |
Correct |
5 ms |
12636 KB |
Output is correct |
24 |
Correct |
4 ms |
12636 KB |
Output is correct |
25 |
Correct |
4 ms |
12836 KB |
Output is correct |
26 |
Correct |
5 ms |
12636 KB |
Output is correct |
27 |
Correct |
5 ms |
12636 KB |
Output is correct |
28 |
Correct |
4 ms |
12636 KB |
Output is correct |
29 |
Correct |
4 ms |
12636 KB |
Output is correct |
30 |
Correct |
3 ms |
12636 KB |
Output is correct |
31 |
Correct |
49 ms |
16988 KB |
Output is correct |
32 |
Correct |
56 ms |
17236 KB |
Output is correct |
33 |
Correct |
29 ms |
16732 KB |
Output is correct |
34 |
Correct |
68 ms |
16976 KB |
Output is correct |
35 |
Correct |
84 ms |
16988 KB |
Output is correct |
36 |
Correct |
73 ms |
16980 KB |
Output is correct |
37 |
Correct |
42 ms |
16732 KB |
Output is correct |
38 |
Correct |
82 ms |
17016 KB |
Output is correct |
39 |
Incorrect |
65 ms |
16988 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |