๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
#define MAXN 30005
vector<int> adj[MAXN];
int value[MAXN];
int xor_from_root[MAXN];
bool visited[MAXN];
void dfs(int node, int xor_val) {
visited[node] = true;
xor_from_root[node] = xor_val ^ value[node];
for (int neighbor : adj[node]) {
if (!visited[neighbor]) {
dfs(neighbor, xor_from_root[node]);
}
}
}
void solve(int N, int Q, vector<int>& values, vector<pair<int, int>>& edges, vector<tuple<int, int, int>>& queries) {
for (int i = 1; i <= N; ++i) {
value[i] = values[i - 1];
}
for (auto& edge : edges) {
int a, b;
tie(a, b) = edge;
adj[a].push_back(b);
adj[b].push_back(a);
}
memset(visited, false, sizeof(visited));
dfs(1, 0);
for (auto& query : queries) {
int u, v, k;
tie(u, v, k) = query;
int path_xor = xor_from_root[u] ^ xor_from_root[v];
bool found = false;
if (path_xor == k) {
found = true;
} else {
for (int i = 1; i <= N; ++i) {
if ((xor_from_root[u] ^ xor_from_root[v] ^ value[i]) == k) {
found = true;
break;
}
}
}
if (found) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
int main() {
int N, Q;
cin >> N >> Q;
vector<int> values(N);
for (int i = 0; i < N; ++i) {
cin >> values[i];
}
vector<pair<int, int>> edges(N - 1);
for (int i = 0; i < N - 1; ++i) {
int a, b;
cin >> a >> b;
edges[i] = {a, b};
}
vector<tuple<int, int, int>> queries(Q);
for (int i = 0; i < Q; ++i) {
int u, v, k;
cin >> u >> v >> k;
queries[i] = {u, v, k};
}
solve(N, Q, values, edges, queries);
return 0;
}
XOR Tree โ
๐2
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Salesforce hiring for below roles :
AMTS role :
Btech 2024 grads with 7 CGPA and above
Apply Here for Referral :
https://forms.gle/D4MMFK6tY4jB8QCu8
AMTS role :
Btech 2024 grads with 7 CGPA and above
Apply Here for Referral :
https://forms.gle/D4MMFK6tY4jB8QCu8
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Wissen Technology is hiring for Java Developer
Eligibility : 2024 passouts , CS/IT Btech/ Mtech , 7.5 CGPA or higher
Send your resume for referral to :
abhay.tripathi@wissen.com
Or
trupthi.shetty@wissen.com
Eligibility : 2024 passouts , CS/IT Btech/ Mtech , 7.5 CGPA or higher
Send your resume for referral to :
abhay.tripathi@wissen.com
Or
trupthi.shetty@wissen.com
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
CarbonMarketsHQ is hiring for Software Engineering Intern
Batches : 2027, 2026, 2025 passouts eligible
Stipend : 10 - 30 k
Remote
https://wellfound.com/jobs/3069069-software-engineering-intern-climate-tech
Batches : 2027, 2026, 2025 passouts eligible
Stipend : 10 - 30 k
Remote
https://wellfound.com/jobs/3069069-software-engineering-intern-climate-tech
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Zemetric hiring for UI / UX Design
20 - 40 k per month
https://wellfound.com/jobs/3067305-ui-ux-design-intern
20 - 40 k per month
https://wellfound.com/jobs/3067305-ui-ux-design-intern
Wellfound (formerly AngelList Talent)
UI/UX Design Intern at Zemetric โข India โข Remote (Work from Home)
Zemetric is hiring a UI/UX Design Intern in India - Apply now on Wellfound!
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Jio is hiring for Graduate Engineer Trainee
Expected Salary: 4-7 LPA
Apply here:
https://careers.jio.com/frmjobdescription.aspx?JBTITLE=vxpFHGTbi/wqGqTPHnXtsA%3D%3D&jbID=IosACTfrHnilV3Z3WUgnNA%3D%3D&funcCode=tBOU2f2ubJIKJJaEorlljoC0jBhJb9cLpWXiiP5HyBU%3D
Expected Salary: 4-7 LPA
Apply here:
https://careers.jio.com/frmjobdescription.aspx?JBTITLE=vxpFHGTbi/wqGqTPHnXtsA%3D%3D&jbID=IosACTfrHnilV3Z3WUgnNA%3D%3D&funcCode=tBOU2f2ubJIKJJaEorlljoC0jBhJb9cLpWXiiP5HyBU%3D
Jio
Graduate Engineer Trainee ( 80272363 )
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
NYX is hiring for Node.js Developer Intern - Remote
Apply here:
https://linkedin.com/jobs/view/3983310195/?alternateChannel=search
Apply here:
https://linkedin.com/jobs/view/3983310195/?alternateChannel=search
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<pair<ll,ll>>solve(ll n,ll m)
{
vector<pair<ll,ll>>path;
ll x=0,y=0;
ll dx=1,dy=1;
while(1)
{
path.push_back({x, y});
ll nx=x+dx;
ll ny=y+dy;
if(nx<0 or nx>=n) dx=-dx;
if(ny<0 or ny>=m) dy=-dy;
x+=dx;
y+=dy;
if((x==0 && y==0) or (x==0 && y==m-1) or (x==n-1 && y==0) or (x==n-1 && y==m-1))
{
path.push_back({x,y});
break;
}
}
return path;
}
signed main()
{
ll n,m; cin>>n>>m;
auto ans=solve(n,m);
for(ll i=0;i<ans.size();i++)
{
cout<<ans[i].first<<" "<<ans[i].second;
if(i!=ans.size()-1) cout<<", ";
}
}
A Ray of Light
Culfit โ
#include <bits/stdc++.h>
#define ll long long
using namespace std;
class FenwickTree {
public:
FenwickTree(ll n) : bit(n + 1, 0) {}
void update(ll index, ll value) {
for (; index < bit.size(); index += index & -index) {
bit[index] += value;
}
}
ll query(ll index) const {
ll sum = 0;
for (; index > 0; index -= index & -index) {
sum += bit[index];
}
return sum;
}
ll rangeQuery(ll left, ll right) const {
return query(right) - query(left - 1);
}
private:
vector<ll> bit;
};
ll solve(vector<ll>& a)
{
ll n=a.size()-1;
vector<ll>compressed(n+1);
vector<ll>values(a.begin()+1,a.end());
sort(values.begin(),values.end());
values.erase(unique(values.begin(),values.end()),values.end());
for (ll i=1;i<=n;i++)
{
a[i]=lower_bound(values.begin(),values.end(),a[i])-values.begin()+1;
}
FenwickTree fenwick(n);
ll count=0;
for (ll j=2;j<=n;j++)
{
if (a[j]<j) count+=fenwick.query(a[j]-1);
if (a[j-1]<j-1) fenwick.update(a[j-1],1);
}
return count;
}
signed main()
{
ll n; cin>>n;
vector<ll>a(n+1);
for (ll i=1;i<=n;i++) cin >> a[i];
cout <<solve(a)<<endl;
return 0;
}
Pairs of equality
Culfit โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1e9 + 7;
int countValidSeries(int n, int m, vector<int>& f) {
vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
if (f[0] == 0) {
for (int j = 1; j <= m; ++j) {
dp[1][j] = 1;
}
} else {
dp[1][f[0]] = 1;
}
for (int i = 2; i <= n; ++i) {
if (f[i-1] == 0) {
for (int j = 1; j <= m; ++j) {
dp[i][j] = dp[i-1][j];
if (j > 1) dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % MOD;
if (j < m) dp[i][j] = (dp[i][j] + dp[i-1][j+1]) % MOD;
}
} else {
int j = f[i-1];
dp[i][j] = dp[i-1][j];
if (j > 1) dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % MOD;
if (j < m) dp[i][j] = (dp[i][j] + dp[i-1][j+1]) % MOD;
}
}
int result = 0;
for (int j = 1; j <= m; ++j) {
result = (result + dp[n][j]) % MOD;
}
return result;
}
Flight Series Counter โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Smallcase is hiring for Frontend Developer
6 months internship opportunity
2025 batch eligible
https://smallcase.freshteam.com/jobs/fvvVYk18XC4B/internship-program-2024
6 months internship opportunity
2025 batch eligible
https://smallcase.freshteam.com/jobs/fvvVYk18XC4B/internship-program-2024
Freshteam
Hiring for Internship Program 2024 for Bengaluru - Internship
Posted by : smallcase | CSS,HTML,JAVASCRIPT,REACTJS,REDUX,NEXT.JS
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
UST is hiring for Developer I - Software Engineer (0-2 years)
Expected Salary: 5-10 LPA
Apply here:
https://usource.ripplehire.com/candidate/?token=8YxWjpwDhdL62DFYUIcQ&lang=en&source=USTLINKEDIN#detail/job/21822
Expected Salary: 5-10 LPA
Apply here:
https://usource.ripplehire.com/candidate/?token=8YxWjpwDhdL62DFYUIcQ&lang=en&source=USTLINKEDIN#detail/job/21822
Ripplehire
UST Careers | Latest jobs at UST - Ripplehire.com
Apply Now! This is a wonderful opportunity. Help your friends by sharing this role with them.