#include <bits/stdc++.h>
using namespace std;
void solve(vector<vector<int>> vv, int operation, int xx, int yy, int &res)
{
for (int i = 1; i < 3; i++)
{
int sum1 = 0;
for (int j = 0; j < vv.size(); j++)
{
sum1 += vv[j][i - 1];
}
int sum2 = 0;
for (int j = 0; j < vv.size(); j++)
{
sum2 += vv[j][i];
}
if (sum1 == sum2)
{
res = min(res, operation);
}
return;
}
for (int i = 0; i < vv.size(); i++)
{
solve(vv, operation, xx, yy, res);
vector<int> p1 = vv[i];
reverse(p1.begin(), p1.end());
solve(vv, operation + yy, xx, yy, res);
vector<int> p2 = vv[i];
int temp1 = p2[0];
int temp2 = p2[1];
int temp3 = p2[2];
p2[2] = temp1;
p2[1] = temp3;
p2[0] = temp2;
solve(vv, operation + xx, xx, yy, res);
vector<int> p3 = vv[i];
temp1 = p2[0];
temp2 = p2[1];
temp3 = p2[2];
p2[2] = temp2;
p2[1] = temp1;
p2[0] = temp3;
solve(vv, operation + xx, xx, yy, res);
}
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
while (t--)
{
int n = 0, m = 0, a = 0, b = 0, c = 0, d = 0, sum = 0, diff = 0, maxN = 0, minN = 0, count = 0, temp = 0;
bool flag = false;
cin >> n;
cin >> m;
int xx;
cin >> xx;
int yy;
cin >> yy;
vector<vector<int>> vv(n, vector<int>(m));
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin >> vv[i][j];
}
}
if (n == 1)
{
cout << -1 << endl;
continue;
}
int res = INT_MAX;
solve(vv, 0, xx, yy, res);
cout << res << endl;
}
return 0;
}
Pay for Gift โ
Infosys
using namespace std;
void solve(vector<vector<int>> vv, int operation, int xx, int yy, int &res)
{
for (int i = 1; i < 3; i++)
{
int sum1 = 0;
for (int j = 0; j < vv.size(); j++)
{
sum1 += vv[j][i - 1];
}
int sum2 = 0;
for (int j = 0; j < vv.size(); j++)
{
sum2 += vv[j][i];
}
if (sum1 == sum2)
{
res = min(res, operation);
}
return;
}
for (int i = 0; i < vv.size(); i++)
{
solve(vv, operation, xx, yy, res);
vector<int> p1 = vv[i];
reverse(p1.begin(), p1.end());
solve(vv, operation + yy, xx, yy, res);
vector<int> p2 = vv[i];
int temp1 = p2[0];
int temp2 = p2[1];
int temp3 = p2[2];
p2[2] = temp1;
p2[1] = temp3;
p2[0] = temp2;
solve(vv, operation + xx, xx, yy, res);
vector<int> p3 = vv[i];
temp1 = p2[0];
temp2 = p2[1];
temp3 = p2[2];
p2[2] = temp2;
p2[1] = temp1;
p2[0] = temp3;
solve(vv, operation + xx, xx, yy, res);
}
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
while (t--)
{
int n = 0, m = 0, a = 0, b = 0, c = 0, d = 0, sum = 0, diff = 0, maxN = 0, minN = 0, count = 0, temp = 0;
bool flag = false;
cin >> n;
cin >> m;
int xx;
cin >> xx;
int yy;
cin >> yy;
vector<vector<int>> vv(n, vector<int>(m));
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin >> vv[i][j];
}
}
if (n == 1)
{
cout << -1 << endl;
continue;
}
int res = INT_MAX;
solve(vv, 0, xx, yy, res);
cout << res << endl;
}
return 0;
}
Pay for Gift โ
Infosys
#include <iostream>
#include <vector>
const int MOD = 1000000007;
using namespace std;
int countBeautifulSequences(int n) {
if (n == 1) {
return 1;
}
vector<int> dp(n + 1, 0);
dp[1] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; ++j) {
dp[j] = (dp[j] + dp[j - i]) % MOD;
}
}
return (dp[n] - 1 + MOD) % MOD;
}
int main() {
int n;
cin >> n;
int result = countBeautifulSequences(n);
cout << result << endl;
return 0;
}
Count Beautiful sequence
#include <vector>
const int MOD = 1000000007;
using namespace std;
int countBeautifulSequences(int n) {
if (n == 1) {
return 1;
}
vector<int> dp(n + 1, 0);
dp[1] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; ++j) {
dp[j] = (dp[j] + dp[j - i]) % MOD;
}
}
return (dp[n] - 1 + MOD) % MOD;
}
int main() {
int n;
cin >> n;
int result = countBeautifulSequences(n);
cout << result << endl;
return 0;
}
Count Beautiful sequence
ll help(ll ans,ll k,map<pair<ll,ll>,ll>&m){
//cout<<ans<<endl;
if(k==0)
return ans;
if(m.find({ans,k})!=m.end())
return m[{ans,k}];
ll a=ans;
for(ll i=30;i>=0;i--){
for(ll j=30;j>=0;j--){
ll k1=(ans|(1LL<<i))^(1LL<<j);
//cout<<k1<<endl;
a=max(a,help(k1,k-1,m));
}
}
m[{ans,k}]=a;
return a;
}
void solve(vector<ll>a,ll k){
ll n=a.size();
ll ans=a[0];
for(ll i=1;i<n;i++){
ans &=a[i];
}
map<pair<ll,ll>,ll>m;
cout<<help(ans,k,m);
}
Limited mask
//cout<<ans<<endl;
if(k==0)
return ans;
if(m.find({ans,k})!=m.end())
return m[{ans,k}];
ll a=ans;
for(ll i=30;i>=0;i--){
for(ll j=30;j>=0;j--){
ll k1=(ans|(1LL<<i))^(1LL<<j);
//cout<<k1<<endl;
a=max(a,help(k1,k-1,m));
}
}
m[{ans,k}]=a;
return a;
}
void solve(vector<ll>a,ll k){
ll n=a.size();
ll ans=a[0];
for(ll i=1;i<n;i++){
ans &=a[i];
}
map<pair<ll,ll>,ll>m;
cout<<help(ans,k,m);
}
Limited mask
int min_operations(string s) {
int n = s.length();
vector<vector<int>> dp(n, vector<int>(n, INT_MAX));
for (int i = 0; i < n; i++) {
dp[i][i] = 0;
}
for (int len = 2; len <= n; len++) {
for (int i = 0; i <= n - len; i++) {
int j = i + len - 1;
if (s[i] == s[j]) {
dp[i][j] = min(dp[i][j], dp[i + 1][j - 1]);
} else {
for (int k = i; k < j; k++) {
dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + 1);
}
}
}
}
return dp[0][n - 1];
}
String Dot
Infosys
int n = s.length();
vector<vector<int>> dp(n, vector<int>(n, INT_MAX));
for (int i = 0; i < n; i++) {
dp[i][i] = 0;
}
for (int len = 2; len <= n; len++) {
for (int i = 0; i <= n - len; i++) {
int j = i + len - 1;
if (s[i] == s[j]) {
dp[i][j] = min(dp[i][j], dp[i + 1][j - 1]);
} else {
for (int k = i; k < j; k++) {
dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + 1);
}
}
}
}
return dp[0][n - 1];
}
String Dot
Infosys
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
const int INF = 1e9;
struct Node {
int value, dist;
Node(int v, int d): value(v), dist(d) {}
};
int main() {
int n, m;
cin >> n >> m;
vector<int> A(n);
vector<vector<int>> graph(n, vector<int>());
vector<vector<int>> dist(n, vector<int>(n, INF));
for (int i = 0; i < n; ++i) {
cin >> A[i];
}
for (int i = 0; i < m; ++i) {
int x, y;
cin >> x >> y;
--x; --y;
graph[x].push_back(y);
graph[y].push_back(x);
dist[x][y] = dist[y][x] = 1;
}
for (int k = 0; k < n; ++k) {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
}
priority_queue<Node, vector<Node>, greater<Node>> pq;
for (int i = 0; i < n; ++i) {
if (A[i] > 0) {
pq.push(Node(i, 0));
}
}
long long cost = 0;
while (!pq.empty()) {
Node node = pq.top();
pq.pop();
int u = node.value;
int d = node.dist;
if (A[u] > 0) {
cost += d * A[u];
A[u] = 0;
for (int v : graph[u]) {
if (A[v] > 0) {
pq.push(Node(v, d + 1));
}
}
}
}
for (int i = 0; i < n; ++i) {
if (A[i] > 0) {
cout << -1 << endl;
return 0;
}
}
cout << cost << endl;
return 0;
}
Tree=0โ
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
const int INF = 1e9;
struct Node {
int value, dist;
Node(int v, int d): value(v), dist(d) {}
};
int main() {
int n, m;
cin >> n >> m;
vector<int> A(n);
vector<vector<int>> graph(n, vector<int>());
vector<vector<int>> dist(n, vector<int>(n, INF));
for (int i = 0; i < n; ++i) {
cin >> A[i];
}
for (int i = 0; i < m; ++i) {
int x, y;
cin >> x >> y;
--x; --y;
graph[x].push_back(y);
graph[y].push_back(x);
dist[x][y] = dist[y][x] = 1;
}
for (int k = 0; k < n; ++k) {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
}
priority_queue<Node, vector<Node>, greater<Node>> pq;
for (int i = 0; i < n; ++i) {
if (A[i] > 0) {
pq.push(Node(i, 0));
}
}
long long cost = 0;
while (!pq.empty()) {
Node node = pq.top();
pq.pop();
int u = node.value;
int d = node.dist;
if (A[u] > 0) {
cost += d * A[u];
A[u] = 0;
for (int v : graph[u]) {
if (A[v] > 0) {
pq.push(Node(v, d + 1));
}
}
}
}
for (int i = 0; i < n; ++i) {
if (A[i] > 0) {
cout << -1 << endl;
return 0;
}
}
cout << cost << endl;
return 0;
}
Tree=0โ
Jai Shree Ram โค
struct Node {
int val;
Node* left;
Node* right;
Node(int val) : val(val), left(NULL), right(NULL) {}
};
Node* expand(Node* root) {
if(root->left == NULL && root->right == NULL) {
root->left = new Node(root->val);
root->right = new Node(root->val);
} else {
if(root->left != NULL) root->left = expand(root->left);
if(root->right != NULL) root->right = expand(root->right);
}
return root;
}
void print(Node* root) {
if(root == NULL) return;
cout << root->val << " ";
print(root->left);
print(root->right);
}
int val;
Node* left;
Node* right;
Node(int val) : val(val), left(NULL), right(NULL) {}
};
Node* expand(Node* root) {
if(root->left == NULL && root->right == NULL) {
root->left = new Node(root->val);
root->right = new Node(root->val);
} else {
if(root->left != NULL) root->left = expand(root->left);
if(root->right != NULL) root->right = expand(root->right);
}
return root;
}
void print(Node* root) {
if(root == NULL) return;
cout << root->val << " ";
print(root->left);
print(root->right);
}
class UserMainCode(object):
@classmethod
def strongString(cls, input1, input2):
n = len(input2)
min_strings = []
for i in range(min(input1, n)):
distribution = [''] * input1
for j in range(n):
distribution[j % input1] += input2[j]
min_string = min(distribution)
min_strings.append(min_string)
result = max(min_strings)
return result
Game of String Distribution โ
int maxSubjectsNumber(vector<int> answered, vector<int> needed, int q) {
int n=answered.size();
vector<int>L;
int c=0;
for(int i=0;i<n;i++)
{
int x=needed[i];
int y=answered[i];
if(x>y)
L.push_back(x-y);
else
c++;
}
sort(L.begin(),L.end());
int p=q;
for(int i=0;i<L.size();i++)
{
int x=L[i];
if(p<x)
break;
p-=x;
c++;
}
return c;
}
int n=answered.size();
vector<int>L;
int c=0;
for(int i=0;i<n;i++)
{
int x=needed[i];
int y=answered[i];
if(x>y)
L.push_back(x-y);
else
c++;
}
sort(L.begin(),L.end());
int p=q;
for(int i=0;i<L.size();i++)
{
int x=L[i];
if(p<x)
break;
p-=x;
c++;
}
return c;
}
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Leap
Role: Engineering Intern
Batch eligible: 2024 passouts only
Apply: https://leapfinance.freshteam.com/jobs/IDtsNXR4UToB/engineering-internship
Role: Engineering Intern
Batch eligible: 2024 passouts only
Apply: https://leapfinance.freshteam.com/jobs/IDtsNXR4UToB/engineering-internship
Freshteam
Hiring for Engineering Internship for Bengaluru - Internship
Posted by : Leap |
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Nexgen is Hiring !!
Role: Full Stack Web Dev Internship
Batch: 2024
๐Apply here:
https://www.nexgi.com/careers/web-internship-php-mysql-stack-with-nginx-apache/
Role: Full Stack Web Dev Internship
Batch: 2024
๐Apply here:
https://www.nexgi.com/careers/web-internship-php-mysql-stack-with-nginx-apache/
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Vinove is Hiring !!
Role: Software Developer- Fresher
Experience: 0-1 years (Batch: 2024 may try)
Location: Noida
๐Apply here: https://vinove.keka.com/careers/jobdetails/52282
Role: Software Developer- Fresher
Experience: 0-1 years (Batch: 2024 may try)
Location: Noida
๐Apply here: https://vinove.keka.com/careers/jobdetails/52282
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐OpenInApp is Hiring !!
Role: Nodejs Developer Intern
Batch: 2024, 2025
๐Apply here:
https://openinapp.freshteam.com/jobs/O8glIz4btVCE/nodejs-developer-intern?ft_source=6000312750&ft_medium=6000257244
Role: Nodejs Developer Intern
Batch: 2024, 2025
๐Apply here:
https://openinapp.freshteam.com/jobs/O8glIz4btVCE/nodejs-developer-intern?ft_source=6000312750&ft_medium=6000257244
Freshteam
Hiring for Nodejs Developer Intern for Bengaluru - Internship
Posted by : OpeninApp | NODE.JS,NODEJS,NODE JS,NODEJS FRAMEWORK,BACKEND DEVELOPMENT,BACKEND FRAMEWORK
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Jar is Hiring !!
Role: Android Developer - Intern
Batch: 2024, 2025
๐Apply here:
https://jobs.lever.co/jar-app/64e9cb31-b06c-4dfc-a1ef-29a1021e0f58
Role: Android Developer - Intern
Batch: 2024, 2025
๐Apply here:
https://jobs.lever.co/jar-app/64e9cb31-b06c-4dfc-a1ef-29a1021e0f58
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Fortive is Hiring !!
Role: SW Intern
Location: Bangalore
๐Apply here: https://careers.fortive.com/job/FORTUSADV003161/SW-Intern
Role: SW Intern
Location: Bangalore
๐Apply here: https://careers.fortive.com/job/FORTUSADV003161/SW-Intern
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Pivotree are looking to onboard Freshers (BSc/B.E /B.Tech) 2023 passout.
Office Location - Bangalore
Eligibility Criteria -
75% & above throughout 10th, 12th & Graduation
Pass out Batch Academic Year 2023
Major Criteria : Should be good in Computer Science core subjects, Database, Data structure, and coding .Good verbal and written skill.
Note - Shortlisted candidates will be called for Assessment Test followed by inperson interview at Bangalore office.
Candidates who have appeared for Aptitude test in last 6 months cannot be considered.
Please apply for the job over email us on vijeta.padwal@pivotree.com/ vedant.jadhav@pivotree.com
Office Location - Bangalore
Eligibility Criteria -
75% & above throughout 10th, 12th & Graduation
Pass out Batch Academic Year 2023
Major Criteria : Should be good in Computer Science core subjects, Database, Data structure, and coding .Good verbal and written skill.
Note - Shortlisted candidates will be called for Assessment Test followed by inperson interview at Bangalore office.
Candidates who have appeared for Aptitude test in last 6 months cannot be considered.
Please apply for the job over email us on vijeta.padwal@pivotree.com/ vedant.jadhav@pivotree.com
Pivotree
eCommerce, Supply Chain and Data Management Services - Pivotree
Pivotree is your single point of contact for all eCommerce, supply chain, MDM, and cloud hosting needs. Expert design, implementation and support services!
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company: Qualcomm
Role: Associate Engineer
Expected CTC: 5.5 - 7.5 LPA
Batch Eligible: 2023 & Before
Website: https://careers.qualcomm.com/careers/job/446696658715?domain=qualcomm.com&source=APPLICANT_SOURCE-6-104
Role: Associate Engineer
Expected CTC: 5.5 - 7.5 LPA
Batch Eligible: 2023 & Before
Website: https://careers.qualcomm.com/careers/job/446696658715?domain=qualcomm.com&source=APPLICANT_SOURCE-6-104