답안 #1060322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060322 2024-08-15T12:57:41 Z aymanrs Sličnost (COI23_slicnost) C++17
24 / 100
3000 ms 6492 KB
#include<bits/stdc++.h>
using namespace std;
const int nx = 4e5+100;
int st[nx], co[nx], lz[nx];
void cons(int i, int l, int r){
    st[i]=lz[i]=0;
    co[i] = r-l+1;
    if(l==r) return;
    int m = l+r>>1;
    cons(i<<1, l, m);cons(i<<1|1, m+1, r);
}
void upd(int i, int l, int r, int a, int b, int v){
    if(lz[i]){
        st[i] += lz[i];
        if(l!=r){
            lz[i<<1] += lz[i];
            lz[i<<1|1] += lz[i];
        }
        lz[i]=0;
    }
    if(b<l||r<a) return;
    if(a <= l && r <= b) {
        st[i] += v;
        if(l!=r){
            lz[i<<1] += v;
            lz[i<<1|1] += v;
        }
        return;
    }
    int m = l+r>>1;
    upd(i<<1, l, m, a, b, v);upd(i<<1|1, m+1, r, a, b, v);
    st[i] = max(st[i<<1], st[i<<1|1]);
    co[i] = 0;
    if(st[i<<1] == st[i]) co[i]=co[i<<1];
    if(st[i<<1|1] == st[i]) co[i]+=co[i<<1|1];
}
void ans(int n, int k, int a[], int b[]){
    cons(1, 0, n-1);
    for(int i = 0;i < k;i++) {
        upd(1, 0, n-1, max(0, b[a[i]]-k+1), min(n-k,b[a[i]]), 1);
    }
    int tans = st[1], c = co[1];
    for(int i = 1;i+k <= n;i++){
        upd(1, 0, n-1, max(0, b[a[i-1]]-k+1), min(n-k,b[a[i-1]]), -1);
        upd(1, 0, n-1, max(0, b[a[i+k-1]]-k+1), min(n-k,b[a[i+k-1]]), 1);
        if(st[1] > tans){
            tans = st[1];
            c = co[1];
        } else if(st[1] == tans) c += co[1];
    }
    cout << tans << ' ' << c << '\n';
}
void solve(){
    int n, k ,q;cin >> n >> k >> q;
    int a[n],b[n+1];
    for(int i = 0;i < n;i++) cin >> a[i];
    for(int i = 0;i < n;i++) {
        int th;cin >> th;
        b[th] = i;
    }
    ans(n, k, a, b);
    while(q--){
        int p;cin >> p;
        p--;
        swap(a[p],a[p+1]);
        ans(n,k,a,b);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Compilation message

Main.cpp: In function 'void cons(int, int, int)':
Main.cpp:9:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    9 |     int m = l+r>>1;
      |             ~^~
Main.cpp: In function 'void upd(int, int, int, int, int, int)':
Main.cpp:30:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |     int m = l+r>>1;
      |             ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 2 ms 4444 KB Output is correct
17 Correct 3 ms 4440 KB Output is correct
18 Correct 2 ms 4444 KB Output is correct
19 Correct 3 ms 4444 KB Output is correct
20 Correct 4 ms 4668 KB Output is correct
21 Correct 4 ms 4668 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 4 ms 4444 KB Output is correct
24 Correct 3 ms 4444 KB Output is correct
25 Correct 3 ms 4668 KB Output is correct
26 Correct 6 ms 4444 KB Output is correct
27 Correct 4 ms 4444 KB Output is correct
28 Correct 3 ms 4444 KB Output is correct
29 Correct 3 ms 4444 KB Output is correct
30 Correct 2 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 2 ms 4444 KB Output is correct
17 Correct 3 ms 4440 KB Output is correct
18 Correct 2 ms 4444 KB Output is correct
19 Correct 3 ms 4444 KB Output is correct
20 Correct 4 ms 4668 KB Output is correct
21 Correct 4 ms 4668 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 4 ms 4444 KB Output is correct
24 Correct 3 ms 4444 KB Output is correct
25 Correct 3 ms 4668 KB Output is correct
26 Correct 6 ms 4444 KB Output is correct
27 Correct 4 ms 4444 KB Output is correct
28 Correct 3 ms 4444 KB Output is correct
29 Correct 3 ms 4444 KB Output is correct
30 Correct 2 ms 4444 KB Output is correct
31 Correct 48 ms 5468 KB Output is correct
32 Correct 53 ms 6492 KB Output is correct
33 Correct 28 ms 6488 KB Output is correct
34 Correct 66 ms 6492 KB Output is correct
35 Correct 98 ms 6492 KB Output is correct
36 Correct 61 ms 6492 KB Output is correct
37 Correct 26 ms 6492 KB Output is correct
38 Correct 94 ms 6492 KB Output is correct
39 Incorrect 63 ms 6492 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 2 ms 4444 KB Output is correct
17 Correct 2 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 2 ms 4600 KB Output is correct
20 Correct 2 ms 4560 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 2 ms 4440 KB Output is correct
23 Correct 2 ms 4444 KB Output is correct
24 Correct 2 ms 4444 KB Output is correct
25 Correct 2 ms 4444 KB Output is correct
26 Correct 2 ms 4444 KB Output is correct
27 Correct 2 ms 4440 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 2 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 2 ms 4444 KB Output is correct
17 Correct 3 ms 4440 KB Output is correct
18 Correct 2 ms 4444 KB Output is correct
19 Correct 3 ms 4444 KB Output is correct
20 Correct 4 ms 4668 KB Output is correct
21 Correct 4 ms 4668 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 4 ms 4444 KB Output is correct
24 Correct 3 ms 4444 KB Output is correct
25 Correct 3 ms 4668 KB Output is correct
26 Correct 6 ms 4444 KB Output is correct
27 Correct 4 ms 4444 KB Output is correct
28 Correct 3 ms 4444 KB Output is correct
29 Correct 3 ms 4444 KB Output is correct
30 Correct 2 ms 4444 KB Output is correct
31 Correct 2 ms 4444 KB Output is correct
32 Correct 2 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 2 ms 4600 KB Output is correct
35 Correct 2 ms 4560 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 2 ms 4440 KB Output is correct
38 Correct 2 ms 4444 KB Output is correct
39 Correct 2 ms 4444 KB Output is correct
40 Correct 2 ms 4444 KB Output is correct
41 Correct 2 ms 4444 KB Output is correct
42 Correct 2 ms 4440 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 2 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Execution timed out 3073 ms 4444 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 2 ms 4444 KB Output is correct
17 Correct 3 ms 4440 KB Output is correct
18 Correct 2 ms 4444 KB Output is correct
19 Correct 3 ms 4444 KB Output is correct
20 Correct 4 ms 4668 KB Output is correct
21 Correct 4 ms 4668 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 4 ms 4444 KB Output is correct
24 Correct 3 ms 4444 KB Output is correct
25 Correct 3 ms 4668 KB Output is correct
26 Correct 6 ms 4444 KB Output is correct
27 Correct 4 ms 4444 KB Output is correct
28 Correct 3 ms 4444 KB Output is correct
29 Correct 3 ms 4444 KB Output is correct
30 Correct 2 ms 4444 KB Output is correct
31 Correct 48 ms 5468 KB Output is correct
32 Correct 53 ms 6492 KB Output is correct
33 Correct 28 ms 6488 KB Output is correct
34 Correct 66 ms 6492 KB Output is correct
35 Correct 98 ms 6492 KB Output is correct
36 Correct 61 ms 6492 KB Output is correct
37 Correct 26 ms 6492 KB Output is correct
38 Correct 94 ms 6492 KB Output is correct
39 Incorrect 63 ms 6492 KB Output isn't correct
40 Halted 0 ms 0 KB -