from collections import deque
def bfs(graph, source, dest):
queue = deque([(source, 0)])
while queue:
node, dist = queue.popleft()
if node == dest:
return dist
for neighbor in graph[node]:
if neighbor != node:
queue.append((neighbor, dist + 1))
return -1
def solve():
t = int(input())
for _ in range(t):
n = int(input())
a, b, c = map(int, input().split())
graph = {}
for _ in range(n - 1):
x, y = map(int, input().split())
if x not in graph:
graph[x] = []
if y not in graph:
graph[y] = []
graph[x].append(y)
graph[y].append(x)
atoc = bfs(graph, a, c)
btoc = bfs(graph, b, c)
atob = bfs(graph, a, b)
if atoc < btoc:
print("A")
elif atob < atoc:
print("B")
elif btoc < atoc:
print("C")
else:
print("DRAW")
if name == "main":
solve()
Three Person โ ICPC
def bfs(graph, source, dest):
queue = deque([(source, 0)])
while queue:
node, dist = queue.popleft()
if node == dest:
return dist
for neighbor in graph[node]:
if neighbor != node:
queue.append((neighbor, dist + 1))
return -1
def solve():
t = int(input())
for _ in range(t):
n = int(input())
a, b, c = map(int, input().split())
graph = {}
for _ in range(n - 1):
x, y = map(int, input().split())
if x not in graph:
graph[x] = []
if y not in graph:
graph[y] = []
graph[x].append(y)
graph[y].append(x)
atoc = bfs(graph, a, c)
btoc = bfs(graph, b, c)
atob = bfs(graph, a, b)
if atoc < btoc:
print("A")
elif atob < atoc:
print("B")
elif btoc < atoc:
print("C")
else:
print("DRAW")
if name == "main":
solve()
Three Person โ ICPC
#include<bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> cust;
for(int i = 0; i < n; i++) {
int q, p;
cin >> q >> p;
cust.push_back({p, q});
}
vector<vector<int>> rice;
for(int i = 0; i < m; i++) {
int q, p;
cin >> q >> p;
rice.push_back({p, q});
}
sort(cust.begin(), cust.end());
sort(rice.begin(), rice.end());
vector<int> x(m, 0);
int ans = 0;
for(int i = 0; i < n; i++) {
int quantity = -1;
int index = -1;
for(int j = 0; j < m; j++) {
if (!x[j]) {
if (rice[j][0] > cust[i][0]) break;
if (rice[j][1] > cust[i][1]) {
if (quantity == -1) {
quantity = rice[j][1];
index = j;
} else {
if (quantity > rice[j][1]) {
index = j;
quantity = rice[j][1];
}
}
}
}
}
if (index != -1) {
x[index] = 1;
ans++;
}
}
cout << ans;
}
Super market Codevita โ
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> cust;
for(int i = 0; i < n; i++) {
int q, p;
cin >> q >> p;
cust.push_back({p, q});
}
vector<vector<int>> rice;
for(int i = 0; i < m; i++) {
int q, p;
cin >> q >> p;
rice.push_back({p, q});
}
sort(cust.begin(), cust.end());
sort(rice.begin(), rice.end());
vector<int> x(m, 0);
int ans = 0;
for(int i = 0; i < n; i++) {
int quantity = -1;
int index = -1;
for(int j = 0; j < m; j++) {
if (!x[j]) {
if (rice[j][0] > cust[i][0]) break;
if (rice[j][1] > cust[i][1]) {
if (quantity == -1) {
quantity = rice[j][1];
index = j;
} else {
if (quantity > rice[j][1]) {
index = j;
quantity = rice[j][1];
}
}
}
}
}
if (index != -1) {
x[index] = 1;
ans++;
}
}
cout << ans;
}
Super market Codevita โ
#include <stdio.h>
int cd=0,ca=0;
void bd(int array[], int n) {
for (int step = 0; step < n - 1; ++step) {
for (int i = 0; i < n - step - 1; ++i) {
if (array[i] < array[i + 1]) {
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
cd++;
}
}
}
}
void ba(int array[], int n) {
for (int step = 0; step < n - 1; ++step) {
for (int i = 0; i < n - step - 1; ++i) {
if (array[i] > array[i + 1]) {
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
ca++;
}
}
}
}
int main() {
int n;
scanf("%d",&n);
int da[n],dd[n];
for(int i=0;i<n;i++){
scanf("%d",&da[i]);
dd[i]=da[i];
}
ba(dd, n);
bd(da, n);
if(cd>ca)
printf("%d",ca);
else
printf("%d",cd);
}
Best Bubble Codevita โ
int cd=0,ca=0;
void bd(int array[], int n) {
for (int step = 0; step < n - 1; ++step) {
for (int i = 0; i < n - step - 1; ++i) {
if (array[i] < array[i + 1]) {
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
cd++;
}
}
}
}
void ba(int array[], int n) {
for (int step = 0; step < n - 1; ++step) {
for (int i = 0; i < n - step - 1; ++i) {
if (array[i] > array[i + 1]) {
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
ca++;
}
}
}
}
int main() {
int n;
scanf("%d",&n);
int da[n],dd[n];
for(int i=0;i<n;i++){
scanf("%d",&da[i]);
dd[i]=da[i];
}
ba(dd, n);
bd(da, n);
if(cd>ca)
printf("%d",ca);
else
printf("%d",cd);
}
Best Bubble Codevita โ
๐2
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
BNY Mellon Code Divas Diversity Challenge
Role: Software Developer
Batch eligible: 2024, 2025 and 2026 passouts
Apply: https://assessment.hackerearth.com/challenges/new/hiring/bny-mellon-women-challenge-2023/
Role: Software Developer
Batch eligible: 2024, 2025 and 2026 passouts
Apply: https://assessment.hackerearth.com/challenges/new/hiring/bny-mellon-women-challenge-2023/
HackerEarth
BNY Mellon Code Divas Diversity Challenge
Update - The test has been concluded early after a great participation volumn by candidates. An official email has been sent to you by HackerEarth informing the same.
BNY Mellon invites you to participate in the transformative challenge - Code Divas. Ourโฆ
BNY Mellon invites you to participate in the transformative challenge - Code Divas. Ourโฆ
๐1
Python 3โ
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Data Analytics Internship
Link!
https://msd.wd5.myworkdayjobs.com/en-US/SearchJobs/job/Data---Analytics-Intern---Data-Solutions_R269314-1
Link!
https://msd.wd5.myworkdayjobs.com/en-US/SearchJobs/job/Data---Analytics-Intern---Data-Solutions_R269314-1
๐ Nissan is Hiring !!
Role: Software Engineer I
Qualification: Bachelor's
Freshers can apply
Batch: 2024
Apply:
https://alliance.wd3.myworkdayjobs.com/en-US/nissanjobs/job/software-engineer-i_r00151957-1
Role: Software Engineer I
Qualification: Bachelor's
Freshers can apply
Batch: 2024
Apply:
https://alliance.wd3.myworkdayjobs.com/en-US/nissanjobs/job/software-engineer-i_r00151957-1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Walmart
Role: Software Engineer Intern
Batch eligible: 2024 passouts
Apply: https://bit.ly/3R3D5mO
Role: Software Engineer Intern
Batch eligible: 2024 passouts
Apply: https://bit.ly/3R3D5mO
๐1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include<bits/stdc++.h>
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL));
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define test(x) int x; cin>>x; while(x--)
#define int long long int
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define input(a,n) for(int i=0;i<n;i++) cin>>a[i];
int M= 1e9+7;
#define endl "\n"
int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) { res*=n-i; res/=i+1; } return res; }
//int f(int n) {if (n >= M) return 0;int result = 1; for (int i = 1; i <= n; i++) result = (result * i) % M;return result;}
using namespace std;
int dx[] = { 0,1,0,-1, -1, 1, 1, -1};
int dy[] = {-1,0,1,0, 1, 1, -1, -1};
int dfs(int node, vector<vector<int>> &adj, vector<bool> &vis, vector<bool> &corrupt)
{
queue<int> q;
int mini = INT_MAX;
q.push(node);
while(!q.empty())
{
int x = q.front();
q.pop();
if(x !=node && !corrupt[x])
mini = min(mini, x);
for(auto it : adj[x])
{
if(!vis[it])
{
q.push(it);
vis[it] = true;
}
}
}
return mini == INT_MAX? -1: mini;
}
int solve()
{
int nodes, edges;
cin >> nodes >> edges;
int n = nodes;
int temp1;
cin >> temp1;
vector<bool> vis(n + 1, false);
vector<vector<int>> adj(n + 1);
for(int i = 0;i < edges;i++)
{
int p, q;
cin >> p >> q;
adj[p].push_back(q);
adj[q].push_back(p);
}
int q;
cin >> q;
int temp;
cin >> temp;
vector<int> ans;
vector<bool> corrupt(n + 1, false);
while(q--)
{
int x, y;
cin >> x >> y;
if(x == 1)
{
vector<bool> vis(n + 1, false);
int mini = y;
if(corrupt[y])
{
mini = dfs(y, adj, vis, corrupt);
}
ans.push_back(mini);
}
else
corrupt[y] = true;
}
for(int i = 0; i < ans.size();i++)
cout << ans[i] << endl;
return 0;
}
signed main() {
solve();
return 0;
}
UBSโ
Dead Pod Recovery
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL));
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define test(x) int x; cin>>x; while(x--)
#define int long long int
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define input(a,n) for(int i=0;i<n;i++) cin>>a[i];
int M= 1e9+7;
#define endl "\n"
int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) { res*=n-i; res/=i+1; } return res; }
//int f(int n) {if (n >= M) return 0;int result = 1; for (int i = 1; i <= n; i++) result = (result * i) % M;return result;}
using namespace std;
int dx[] = { 0,1,0,-1, -1, 1, 1, -1};
int dy[] = {-1,0,1,0, 1, 1, -1, -1};
int dfs(int node, vector<vector<int>> &adj, vector<bool> &vis, vector<bool> &corrupt)
{
queue<int> q;
int mini = INT_MAX;
q.push(node);
while(!q.empty())
{
int x = q.front();
q.pop();
if(x !=node && !corrupt[x])
mini = min(mini, x);
for(auto it : adj[x])
{
if(!vis[it])
{
q.push(it);
vis[it] = true;
}
}
}
return mini == INT_MAX? -1: mini;
}
int solve()
{
int nodes, edges;
cin >> nodes >> edges;
int n = nodes;
int temp1;
cin >> temp1;
vector<bool> vis(n + 1, false);
vector<vector<int>> adj(n + 1);
for(int i = 0;i < edges;i++)
{
int p, q;
cin >> p >> q;
adj[p].push_back(q);
adj[q].push_back(p);
}
int q;
cin >> q;
int temp;
cin >> temp;
vector<int> ans;
vector<bool> corrupt(n + 1, false);
while(q--)
{
int x, y;
cin >> x >> y;
if(x == 1)
{
vector<bool> vis(n + 1, false);
int mini = y;
if(corrupt[y])
{
mini = dfs(y, adj, vis, corrupt);
}
ans.push_back(mini);
}
else
corrupt[y] = true;
}
for(int i = 0; i < ans.size();i++)
cout << ans[i] << endl;
return 0;
}
signed main() {
solve();
return 0;
}
UBSโ
Dead Pod Recovery
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Oracle Hiring Intern
Batch : 2024, 2025 batch
Experience: Students
Salary :50k - 75k per mont ( Expected)
Application link : https://eeho.fa.us2.oraclecloud.com/hcmUI/CandidateExperience/en/sites/jobsearch/job/217181
Batch : 2024, 2025 batch
Experience: Students
Salary :50k - 75k per mont ( Expected)
Application link : https://eeho.fa.us2.oraclecloud.com/hcmUI/CandidateExperience/en/sites/jobsearch/job/217181
Oracle
Student / Intern
Pipeline req for GBF FY25 Hiring. Internal and any other External applicants are not eligible.