Submission #947281

# Submission time Handle Problem Language Result Execution time Memory
947281 2024-03-15T20:52:57 Z SuPythony Bliskost (COI23_bliskost) C++17
28 / 100
128 ms 24176 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
class BIT {
    vector<int> bit;
    int size;
    
    public:
        BIT(int n, vector<int> vals) {
            bit.resize(n+1,0);
            size=n;
            for (int i=1; i<=n; i++) {
                update(i,vals[i]);
            }
        }
        
        void update(int pos, int val) {
            while (pos<=size) {
                bit[pos]+=val;
                pos+=pos&-pos;
            }
        }
        
        int query(int pos) {
            int ans=0;
            while (pos>0) {
                ans+=bit[pos];
                pos-=pos&-pos;
            }
            return ans;
        }
};
 
int main() {
    int n,q; cin>>n>>q;
    string a,b; cin>>a>>b;
    vector<int> va, vb;
    va.push_back(0);
    vb.push_back(0);
    for (int i=1; i<=n; i++) {
        if (n%2==i%2) {
            va.push_back(a[i-1]-'a'+1);
            vb.push_back(b[i-1]-'a'+1);
        } else {
            va.push_back(-(a[i-1]-'a'+1));
            vb.push_back(-(b[i-1]-'a'+1));
        }
    }
    BIT fa=BIT(n,va);
    BIT fb=BIT(n,vb);
    if ((fa.query(n)-fb.query(n))%26==0) cout<<"da\n";
    else cout<<"ne\n";
    while (q--) {
        int p; char a; cin>>p>>a;
        if (n%2==p%2) fa.update(p,(a-'a'+1)-va[p]);
        else fa.update(p,-(a-'a'+1)-va[p]);
        va[p]=a-'a'+1;
        if ((fa.query(n)-fb.query(n))%26==0) cout<<"da\n";
        else cout<<"ne\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 388 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 344 KB Output is correct
15 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 436 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 388 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 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 436 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 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 436 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 388 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 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 436 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 64 ms 23720 KB Output is correct
32 Correct 56 ms 23892 KB Output is correct
33 Correct 57 ms 23788 KB Output is correct
34 Correct 55 ms 23888 KB Output is correct
35 Correct 56 ms 24176 KB Output is correct
36 Correct 73 ms 23744 KB Output is correct
37 Correct 56 ms 23900 KB Output is correct
38 Correct 67 ms 24028 KB Output is correct
39 Correct 58 ms 23908 KB Output is correct
40 Correct 55 ms 23796 KB Output is correct
41 Correct 56 ms 23984 KB Output is correct
42 Correct 57 ms 23792 KB Output is correct
43 Correct 56 ms 23892 KB Output is correct
44 Correct 58 ms 24132 KB Output is correct
45 Correct 56 ms 23896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 388 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 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Incorrect 128 ms 960 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 388 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 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 436 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Incorrect 128 ms 960 KB Output isn't correct
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 436 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 388 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 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 436 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 64 ms 23720 KB Output is correct
32 Correct 56 ms 23892 KB Output is correct
33 Correct 57 ms 23788 KB Output is correct
34 Correct 55 ms 23888 KB Output is correct
35 Correct 56 ms 24176 KB Output is correct
36 Correct 73 ms 23744 KB Output is correct
37 Correct 56 ms 23900 KB Output is correct
38 Correct 67 ms 24028 KB Output is correct
39 Correct 58 ms 23908 KB Output is correct
40 Correct 55 ms 23796 KB Output is correct
41 Correct 56 ms 23984 KB Output is correct
42 Correct 57 ms 23792 KB Output is correct
43 Correct 56 ms 23892 KB Output is correct
44 Correct 58 ms 24132 KB Output is correct
45 Correct 56 ms 23896 KB Output is correct
46 Incorrect 128 ms 960 KB Output isn't correct
47 Halted 0 ms 0 KB -