# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
925609 |
2024-02-12T06:16:05 Z |
Amr |
Sličnost (COI23_slicnost) |
C++14 |
|
3000 ms |
860 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);
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;
}
ll n , k, q;
const int N = 5001;
ll cnt[N];
int a[N];
int b[N];
int al[N];
void cal()
{
memset(al,0,sizeof al);
memset(cnt,0,sizeof cnt);
for(int i = 1; i < k; i++)
cnt[a[i]]++;
ll ans = 0;
for(int j = k; j <= n ;j++)
{
ans = 0;
cnt[a[j]]++;
cnt[a[j-k]]--;
if(cnt[a[j]]==2) ans++;
if(cnt[a[j-k]]==1) ans--;
//
for(int i = 1; i < k; i++)
{
cnt[b[i]]++; if(cnt[b[i]]==2) ans++;
}
//
for(int i = k; i <= n; i++)
{
cnt[b[i]]++; if(cnt[b[i]]==2) ans++;
cnt[b[i-k]]--; if(cnt[b[i-k]]==1) ans--;
// cout << ans << " " << j << " " << i << " " << 'h' << endl;
al[ans]++;
}
for(int i = n-k+1; i <= n; i++) cnt[b[i]]--;
}
}
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];
cal();
for(int i = n; i>= 1; i--)
{
if(al[i]){cout << i << " " << al[i] << endl; break;}
}
while(q--)
{
ll l; cin >> l;
swap(a[l],a[l+1]);
cal();
for(int i = n; i>= 1; i--)
{
if(al[i]){cout << i << " " << al[i] << endl; break;}
}
}
}
int main(){
//freopen("friday.in","r",stdin);
//freopen("friday.out","w",stdout);
fast;
while(TT--)
solve();
return 0;
}
Compilation message
Main.cpp: In function 'void cal()':
Main.cpp:41:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
41 | for(int i = 1; i < k; i++)
| ^~~
Main.cpp:43:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
43 | ll ans = 0;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
96 ms |
604 KB |
Output is correct |
17 |
Correct |
88 ms |
600 KB |
Output is correct |
18 |
Correct |
1 ms |
600 KB |
Output is correct |
19 |
Correct |
23 ms |
604 KB |
Output is correct |
20 |
Correct |
54 ms |
604 KB |
Output is correct |
21 |
Correct |
49 ms |
592 KB |
Output is correct |
22 |
Correct |
3 ms |
348 KB |
Output is correct |
23 |
Correct |
67 ms |
348 KB |
Output is correct |
24 |
Correct |
55 ms |
600 KB |
Output is correct |
25 |
Correct |
29 ms |
344 KB |
Output is correct |
26 |
Correct |
35 ms |
604 KB |
Output is correct |
27 |
Correct |
46 ms |
348 KB |
Output is correct |
28 |
Correct |
25 ms |
344 KB |
Output is correct |
29 |
Correct |
19 ms |
600 KB |
Output is correct |
30 |
Correct |
6 ms |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
96 ms |
604 KB |
Output is correct |
17 |
Correct |
88 ms |
600 KB |
Output is correct |
18 |
Correct |
1 ms |
600 KB |
Output is correct |
19 |
Correct |
23 ms |
604 KB |
Output is correct |
20 |
Correct |
54 ms |
604 KB |
Output is correct |
21 |
Correct |
49 ms |
592 KB |
Output is correct |
22 |
Correct |
3 ms |
348 KB |
Output is correct |
23 |
Correct |
67 ms |
348 KB |
Output is correct |
24 |
Correct |
55 ms |
600 KB |
Output is correct |
25 |
Correct |
29 ms |
344 KB |
Output is correct |
26 |
Correct |
35 ms |
604 KB |
Output is correct |
27 |
Correct |
46 ms |
348 KB |
Output is correct |
28 |
Correct |
25 ms |
344 KB |
Output is correct |
29 |
Correct |
19 ms |
600 KB |
Output is correct |
30 |
Correct |
6 ms |
432 KB |
Output is correct |
31 |
Runtime error |
2 ms |
860 KB |
Execution killed with signal 11 |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
464 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
460 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
348 KB |
Output is correct |
24 |
Correct |
2 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
348 KB |
Output is correct |
27 |
Correct |
4 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
520 KB |
Output is correct |
29 |
Correct |
2 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
96 ms |
604 KB |
Output is correct |
17 |
Correct |
88 ms |
600 KB |
Output is correct |
18 |
Correct |
1 ms |
600 KB |
Output is correct |
19 |
Correct |
23 ms |
604 KB |
Output is correct |
20 |
Correct |
54 ms |
604 KB |
Output is correct |
21 |
Correct |
49 ms |
592 KB |
Output is correct |
22 |
Correct |
3 ms |
348 KB |
Output is correct |
23 |
Correct |
67 ms |
348 KB |
Output is correct |
24 |
Correct |
55 ms |
600 KB |
Output is correct |
25 |
Correct |
29 ms |
344 KB |
Output is correct |
26 |
Correct |
35 ms |
604 KB |
Output is correct |
27 |
Correct |
46 ms |
348 KB |
Output is correct |
28 |
Correct |
25 ms |
344 KB |
Output is correct |
29 |
Correct |
19 ms |
600 KB |
Output is correct |
30 |
Correct |
6 ms |
432 KB |
Output is correct |
31 |
Correct |
4 ms |
464 KB |
Output is correct |
32 |
Correct |
3 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
2 ms |
460 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
2 ms |
348 KB |
Output is correct |
38 |
Correct |
2 ms |
348 KB |
Output is correct |
39 |
Correct |
2 ms |
348 KB |
Output is correct |
40 |
Correct |
1 ms |
468 KB |
Output is correct |
41 |
Correct |
3 ms |
348 KB |
Output is correct |
42 |
Correct |
4 ms |
348 KB |
Output is correct |
43 |
Correct |
1 ms |
520 KB |
Output is correct |
44 |
Correct |
2 ms |
348 KB |
Output is correct |
45 |
Correct |
1 ms |
344 KB |
Output is correct |
46 |
Execution timed out |
3064 ms |
604 KB |
Time limit exceeded |
47 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
96 ms |
604 KB |
Output is correct |
17 |
Correct |
88 ms |
600 KB |
Output is correct |
18 |
Correct |
1 ms |
600 KB |
Output is correct |
19 |
Correct |
23 ms |
604 KB |
Output is correct |
20 |
Correct |
54 ms |
604 KB |
Output is correct |
21 |
Correct |
49 ms |
592 KB |
Output is correct |
22 |
Correct |
3 ms |
348 KB |
Output is correct |
23 |
Correct |
67 ms |
348 KB |
Output is correct |
24 |
Correct |
55 ms |
600 KB |
Output is correct |
25 |
Correct |
29 ms |
344 KB |
Output is correct |
26 |
Correct |
35 ms |
604 KB |
Output is correct |
27 |
Correct |
46 ms |
348 KB |
Output is correct |
28 |
Correct |
25 ms |
344 KB |
Output is correct |
29 |
Correct |
19 ms |
600 KB |
Output is correct |
30 |
Correct |
6 ms |
432 KB |
Output is correct |
31 |
Runtime error |
2 ms |
860 KB |
Execution killed with signal 11 |
32 |
Halted |
0 ms |
0 KB |
- |