๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.7K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
vector<long long> solve(vector<int> &A, vector<vector<int>> &B) {
    int n = A.size();
    vector<long long> result;

    for (auto &query : B) {
        int rdx= query[0];
        int l = query[1] - 1; 
        int r = query[2] - 1; 
        int v = query[3];

        if (rdx == 1) {
            for (int i = l; i <= r; ++i) {
                A[i] = v;
            }
        } else if (rdx == 2) {
            for (int i = l; i <= r; ++i) {
                A[i] |= v;
            }
        } else if (rdx == 3) {
            long long ans = 0;
            for (int len = 1; len <= r - l + 1; ++len) {
                for (int i = l; i + len <= r + 1; ++i) {
                    long long subarray_and = A[i];
                    for (int j = i + 1; j < i + len; ++j) {
                        subarray_and &= A[j];
                    }
                    ans += subarray_and;
                }
            }
            result.push_back(ans);
        }
    }
    return result;
}

1st
Trilogy โœ…
int inf = 2e9;
vector<int> solution(int a, vector<vector<int>>& B) {
    int m = B.size();
    vector<int> ans(a + 1, -1);
    vector<int> done(m);
    for (auto x : B) ans[x[1]] = m + 1;
    for (int i = 1; i <= a; i++) {
        if (ans[i] == m + 1) continue;
        int curr = inf, taken = -1;
        for (int j = 0; j < m; j++) {
            int start = i;
            int days = 0, comp = -1;
            int l = 0;
            while (start < a + 1) {
                if (ans[start] == m + 1) {
                    start++;
                    continue;
                }
                days++, start++;
                if (days == B[j][2]) {
                    l = 1;
                    comp = start - 1;
                    break;
                }
            }
            if (!done[j] and B[j][0] <= i and comp < B[j][1] and l) {
                if (B[j][1] < curr) {
                    curr = B[j][1], taken = j;
                }
            }
        }
        if (taken == -1) {
            ans[i] = 0;
            continue;
        }
        B[taken][2]--;
        ans[i] = taken + 1;
        if (!B[taken][2]) done[taken] = 1;
    }
    int d = 0;
    for (auto x : done)
        if (!x) d = 1;
    if (d) {
        vector<int> ret(1, -1);
        return ret;
    } else
        return ans;
}


2nd
Trilogy โœ…
#include <bits/stdc++.h>
using namespace std;

int main ()
{
  int n; cin >> n;
  vector<int> b(n), a;
  for (auto & x : b) cin >> x;

  int X; cin >> X;
  for (int i = 0; i < X; i++) {
    vector<int> newb(n);
    for (int i = 0; i < n; i++) {
      newb[i] = abs(b[i] - b[(i+1)%n]);
    }
    a = b;
    b = newb;   
  }
  cout << "A: ";
  for (auto x : a) cout << x << " ";
  cout << endl;
  cout << "B: ";
  for (auto x : b) cout << x << " ";
  cout << endl;
}


Micron โœ