답안 #954463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954463 2024-03-28T02:13:12 Z GrandTiger1729 Bliskost (COI23_bliskost) C++17
57 / 100
1000 ms 295224 KB
#include <bits/stdc++.h>
using namespace std;

const int K = 26;
struct SegTree
{
    int l, r, mid;
    SegTree *lc, *rc;
    int val[K]{};
    SegTree(const vector<int> &a, int l_, int r_) : l(l_), r(r_)
    {
        mid = (l + r) / 2;
        if (l == r - 1)
        {
            for (int j = 0; j < K; j++)
            {
                val[j] = (a[l] - j + K) % K;
            }
            return;
        }
        lc = new SegTree(a, l, mid);
        rc = new SegTree(a, mid, r);
        pull();
    }
    void pull()
    {
        for (int i = 0; i < K; i++)
        {
            val[i] = rc->val[lc->val[i]];
        }
    }
    void update(int i, int u)
    {
        if (l == r - 1)
        {
            for (int j = 0; j < K; j++)
            {
                val[j] = (u - j + K) % K;
            }
            return;
        }
        if (i < mid)
        {
            lc->update(i, u);
        }
        else
        {
            rc->update(i, u);
        }
        pull();
    }
    void query(int &cur, int ll, int rr)
    {
        if (ll <= l && rr >= r)
        {
            cur = val[cur];
            return;
        }
        if (ll < mid)
        {
            lc->query(cur, ll, rr);
        }
        if (mid < rr)
        {
            rc->query(cur, ll, rr);
        }
    }
};
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    string a, b;
    cin >> a >> b;
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        c[i] = (b[i] - a[i] + K) % K;
    }
    SegTree st(c, 0, n);
    int cur = 0;
    st.query(cur, 0, n);
    cout << (cur == 0 ? "da" : "ne") << '\n';
    while (q--)
    {
        int j;
        char x;
        cin >> j >> x;
        j--;
        a[j] = x;
        st.update(j, (b[j] - a[j] + K) % K);
        cur = 0;
        st.query(cur, 0, n);
        cout << (cur == 0 ? "da" : "ne") << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 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 348 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 0 ms 456 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 596 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 0 ms 412 KB Output is correct
# 결과 실행 시간 메모리 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 348 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 0 ms 456 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 596 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 0 ms 412 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 708 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 856 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 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 348 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 0 ms 456 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 596 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 0 ms 412 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 708 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 856 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 269 ms 288844 KB Output is correct
32 Correct 219 ms 289412 KB Output is correct
33 Correct 215 ms 289812 KB Output is correct
34 Correct 220 ms 289372 KB Output is correct
35 Correct 223 ms 289656 KB Output is correct
36 Correct 205 ms 289760 KB Output is correct
37 Correct 210 ms 289628 KB Output is correct
38 Correct 205 ms 289808 KB Output is correct
39 Correct 203 ms 289772 KB Output is correct
40 Correct 206 ms 289796 KB Output is correct
41 Correct 221 ms 289728 KB Output is correct
42 Correct 230 ms 289664 KB Output is correct
43 Correct 210 ms 289756 KB Output is correct
44 Correct 218 ms 289828 KB Output is correct
45 Correct 208 ms 289932 KB Output is correct
# 결과 실행 시간 메모리 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 348 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 0 ms 456 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 596 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 0 ms 412 KB Output is correct
16 Correct 18 ms 1116 KB Output is correct
17 Correct 18 ms 1112 KB Output is correct
18 Correct 18 ms 1148 KB Output is correct
19 Correct 18 ms 1108 KB Output is correct
20 Correct 18 ms 1128 KB Output is correct
21 Correct 18 ms 1116 KB Output is correct
22 Correct 18 ms 1116 KB Output is correct
23 Correct 18 ms 1116 KB Output is correct
24 Correct 18 ms 1112 KB Output is correct
25 Correct 18 ms 1072 KB Output is correct
26 Correct 18 ms 1116 KB Output is correct
27 Correct 19 ms 1116 KB Output is correct
28 Correct 20 ms 1116 KB Output is correct
29 Correct 23 ms 992 KB Output is correct
30 Correct 18 ms 932 KB Output is correct
# 결과 실행 시간 메모리 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 348 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 0 ms 456 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 596 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 0 ms 412 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 708 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 856 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 18 ms 1116 KB Output is correct
32 Correct 18 ms 1112 KB Output is correct
33 Correct 18 ms 1148 KB Output is correct
34 Correct 18 ms 1108 KB Output is correct
35 Correct 18 ms 1128 KB Output is correct
36 Correct 18 ms 1116 KB Output is correct
37 Correct 18 ms 1116 KB Output is correct
38 Correct 18 ms 1116 KB Output is correct
39 Correct 18 ms 1112 KB Output is correct
40 Correct 18 ms 1072 KB Output is correct
41 Correct 18 ms 1116 KB Output is correct
42 Correct 19 ms 1116 KB Output is correct
43 Correct 20 ms 1116 KB Output is correct
44 Correct 23 ms 992 KB Output is correct
45 Correct 18 ms 932 KB Output is correct
46 Correct 35 ms 1372 KB Output is correct
47 Correct 36 ms 1604 KB Output is correct
48 Correct 36 ms 1568 KB Output is correct
49 Correct 35 ms 1508 KB Output is correct
50 Correct 36 ms 1396 KB Output is correct
51 Correct 36 ms 1380 KB Output is correct
52 Correct 36 ms 1572 KB Output is correct
53 Correct 35 ms 1364 KB Output is correct
54 Correct 36 ms 1364 KB Output is correct
55 Correct 35 ms 1372 KB Output is correct
56 Correct 43 ms 1636 KB Output is correct
57 Correct 35 ms 1552 KB Output is correct
58 Correct 35 ms 1364 KB Output is correct
59 Correct 35 ms 1536 KB Output is correct
60 Correct 39 ms 1352 KB Output is correct
# 결과 실행 시간 메모리 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 348 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 0 ms 456 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 596 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 0 ms 412 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 708 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 856 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 269 ms 288844 KB Output is correct
32 Correct 219 ms 289412 KB Output is correct
33 Correct 215 ms 289812 KB Output is correct
34 Correct 220 ms 289372 KB Output is correct
35 Correct 223 ms 289656 KB Output is correct
36 Correct 205 ms 289760 KB Output is correct
37 Correct 210 ms 289628 KB Output is correct
38 Correct 205 ms 289808 KB Output is correct
39 Correct 203 ms 289772 KB Output is correct
40 Correct 206 ms 289796 KB Output is correct
41 Correct 221 ms 289728 KB Output is correct
42 Correct 230 ms 289664 KB Output is correct
43 Correct 210 ms 289756 KB Output is correct
44 Correct 218 ms 289828 KB Output is correct
45 Correct 208 ms 289932 KB Output is correct
46 Correct 18 ms 1116 KB Output is correct
47 Correct 18 ms 1112 KB Output is correct
48 Correct 18 ms 1148 KB Output is correct
49 Correct 18 ms 1108 KB Output is correct
50 Correct 18 ms 1128 KB Output is correct
51 Correct 18 ms 1116 KB Output is correct
52 Correct 18 ms 1116 KB Output is correct
53 Correct 18 ms 1116 KB Output is correct
54 Correct 18 ms 1112 KB Output is correct
55 Correct 18 ms 1072 KB Output is correct
56 Correct 18 ms 1116 KB Output is correct
57 Correct 19 ms 1116 KB Output is correct
58 Correct 20 ms 1116 KB Output is correct
59 Correct 23 ms 992 KB Output is correct
60 Correct 18 ms 932 KB Output is correct
61 Correct 35 ms 1372 KB Output is correct
62 Correct 36 ms 1604 KB Output is correct
63 Correct 36 ms 1568 KB Output is correct
64 Correct 35 ms 1508 KB Output is correct
65 Correct 36 ms 1396 KB Output is correct
66 Correct 36 ms 1380 KB Output is correct
67 Correct 36 ms 1572 KB Output is correct
68 Correct 35 ms 1364 KB Output is correct
69 Correct 36 ms 1364 KB Output is correct
70 Correct 35 ms 1372 KB Output is correct
71 Correct 43 ms 1636 KB Output is correct
72 Correct 35 ms 1552 KB Output is correct
73 Correct 35 ms 1364 KB Output is correct
74 Correct 35 ms 1536 KB Output is correct
75 Correct 39 ms 1352 KB Output is correct
76 Execution timed out 1058 ms 295224 KB Time limit exceeded
77 Halted 0 ms 0 KB -