Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Aris12345

Автор Aris12345, история, 3 года назад, По-английски

Hello,

I am recently training to qualify for IOI 2022, and I wonder if there is a list of problems from OI problems that I should solve in order to qualify for IOI and do well in it. If you happen to know any such list, please mention it in the comments.

Thanks in advance,

Полный текст и комментарии »

  • Проголосовать: нравится
  • -5
  • Проголосовать: не нравится

Автор Aris12345, история, 4 года назад, По-английски

Hello,

Is there any online judge where I can submit ejoi 2018 — 2020 past problems? I know that past jboi problems and ejoi 2017 problems can be found here: https://mendo.mk/Training.do?cid=2. Also, do you know where can I find jboi 2019 problems?

Thanks!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

Автор Aris12345, история, 4 года назад, По-английски

Hello, Happy New Year!

I am trying to solve this problem: https://codeforces.me/edu/course/2/lesson/4/1/practice/contest/273169/problem/C But my code isn't working(Wrong Answer). Could you help me find my bug?

Here is my code:

#include <bits/stdc++.h>
using namespace std;

int n, m, a[100005], k, l, r;
pair<int, int> st[400005];

pair<int, int> combine(pair<int, int> a, pair<int, int> b) {
    if(a.first < b.first) return a;
    if(b.first < a.first) return b;
    return {a.first, a.second+b.second};
}

void build(int node, int left, int right) {
    if(left == right) st[node] = {a[left], 1};
    else {
        int mid = (left+right)/2;
        build(2*node, left, mid);
        build(2*node+1, mid+1, right);
        st[node] = combine(st[2*node], st[2*node+1]);
    }
}

void update(int node, int left, int right, int x, int y) {
    if(left == right) st[node] = {y, 1};
    else {
        int mid = (left+right)/2;
        if(x <= mid) update(2*node, left, mid, x, y);
        else update(2*node+1, mid+1, right, x, y);
        st[node] = combine(st[2*node], st[2*node+1]);
    }
}

pair<int, int> query(int node, int left, int right, int x, int y) {
    if(x >= right || left >= y) return {INT_MAX, 0};
    if(left >= x && y >= right) return st[node];
    int mid = (left+right)/2;
    pair<int, int> s1 = query(2*node, left, mid, x, y);
    pair<int, int> s2 = query(2*node+1, mid+1, right, x, y);
    return combine(s1, s2);
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    build(1, 1, n);
    while(m--) {
        cin >> k >> l >> r, ++l;
        if(k == 1) update(1, 1, n, l, r);
        else {
            pair<int, int> ans = query(1, 1, n, l, r);
            cout << ans.first << " " << ans.second << "\n";
        }
    }
    return 0;
}

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор Aris12345, история, 4 года назад, По-английски

Hello, I am trying to solve this problem: https://cses.fi/problemset/task/1651. I don't know where my code is wrong, can you help me.

here is my code:

#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1000005;

int n, q, arr[MAXN], bit[MAXN];

void update(int x, int y) {
    for (; x <= n; x += x&-x) bit[x] += y;
}

int query(int x) {
    int ans = 0;
    for (; x > 0; x -= x&-x) ans += bit[x];
    return ans;
}

void range(int x, int y, int z) {
    update(x, z);
    update(y+1, -z);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        update(i, arr[i]);
    }
    while (q--) {
        int x, y, z, w;
        cin >> x;
        if (x == 1) { cin >> y >> z >> w; range(y, z, w); }
        else { cin >> y; cout << query(y)-query(y-1) << "\n"; }
    }
    return 0;
}

Thanks for your time!!!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

Автор Aris12345, история, 4 года назад, По-английски

I am trying to solve this problem: https://cses.fi/problemset/task/1648/ using Binary Indexed Tree. My solution does not work, but I think it is correct.

Heres is my code:

#include <bits/stdc++.h>
using namespace std;

const long MAXN = 2e5+5;

long n, q, arr[MAXN];
long long bit[MAXN];

void update(long x, long y) {
    for (; x <= n; x += x&-x) bit[x] += y;
}

long long query(long x) {
    long long sum = 0;
    for (; x > 0; x -= x&-x) sum += bit[x];
    return sum;
}

long long sum(long l, long r) { return query(r) - query(l-1); }

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> q;
    for (long i = 1; i <= n; i++) {
        cin >> arr[i];
        update(i, arr[i]);
    }
    while (q--) {
        long i, a, b;
        cin >> i >> a >> b;
        if (i == 1) update(a, b-bit[a]);
        else cout << sum(a, b) << "\n";
    }
    return 0;
}

Thanks for your time!!!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится