๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }
int main() {
int H; int W; int K;
while (~scanf("%d%d%d", &H, &W, &K)) {
vector<string> maze(H);
rep(i, H) {
char buf[101];
scanf("%s", buf);
maze[i] = buf;
}
vector<int> tunnel(H * W, -1);
rep(i, K) {
int y1; int x1; int y2; int x2;
scanf("%d%d%d%d", &y1, &x1, &y2, &x2), -- y1, -- x1, -- y2, -- x2;
int u = y1 * W + x1, v = y2 * W + x2;
tunnel[u] = v;
tunnel[v] = u;
}
vector<vector<pair<int, double>>> gw(H * W);
rep(i, H) rep(j, W) {
int u = i * W + j;
if (!strchr("#*%", maze[i][j])) {
static const int dy[4] = { 0, 1, 0, -1 }, dx[4] = { 1, 0, -1, 0 };
for (int d = 0; d < 4; ++ d) {
int yy = i + dy[d], xx = j + dx[d];
if (yy < 0 || yy >= H || xx < 0 || xx >= W) continue;
if (maze[yy][xx] == '#') continue;
int v = yy * W + xx;
if (tunnel[v] != -1)
v = tunnel[v];
gw[u].emplace_back(v, 1.);
}
}
if (gw[u].empty()) {
gw[u].emplace_back(u, 1.);
} else {
for(auto &p : gw[u])
p.second /= (int)gw[u].size();
}
}
//(1 - A)^{-1} c
typedef double Num;
vector<vector<Num>> A(H * W, vector<Num>(H * W)), B = A;
rep(u, H * W) for (auto e : gw[u])
A[u][e.first] += e.second;
rep(iter, 20) {
rep(i, H * W) rep(j, H * W) {
Num x = 0;
rep(k, H * W)
x += A[i][k] * A[k][j];
if (x < 1e-20)
x = 0;
B[i][j] = x;
}
A.swap(B);
}
double ans = 0;
rep(i, H) rep(j, W) if (maze[i][j] == 'A')
rep(k, H) rep(l, W) if(maze[k][l] == '%')
ans += A[i * W + j][k * W + l];
printf("%.10f\n", ans);
}
return 0;
}
Frog in maze โ
#include <bits/stdc++.h>
using namespace std;
#define IDX 0
#define COUNT 1
int MaxNonOverlapSegments(const vector<int>& nums)
{
int size_ = nums.size();
if (size_ < 2) return 0;
int max_count = 1;
unordered_map<int, vector<int>> sum_;
for (int i = 0; i + 1 < size_; ++i)
{
auto it = sum_.find(nums[i] + nums[i + 1]);
if (sum_.end() == it)
{
sum_.emplace(nums[i] + nums[i + 1], vector<int>{i + 1, 1});
continue;
}
vector<int>& val = it->second;
if (val[IDX] + 1 > i)
{
continue;
}
val[IDX] = i + 1;
++val[COUNT];
max_count = max(max_count, val[COUNT]);
}
return max_count;
}
Palo Alto โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <string>
using namespace std;
string solution(string &S, string &T) {
int n = S.size();
int m = T.size();
if (S == T) {
return "NOTHING";
}
if (m == n + 1 && T.substr(0, n) == S) {
return "ADD " + string(1, T[n]);
}
if (n == m + 1) {
for (int i = 0; i < n - 1; i++) {
if (S[i] == S[i + 1]) {
string mergedS = S.substr(0, i) + S.substr(i + 1);
if (mergedS == T) {
return "JOIN " + string(1, S[i]);
}
}
}
}
if (n == m) {
int first_diff = -1, second_diff = -1;
for (int i = 0; i < n; ++i) {
if (S[i] != T[i]) {
if (first_diff == -1) {
first_diff = i;
} else if (second_diff == -1) {
second_diff = i;
} else {
return "IMPOSSIBLE";
}
}
}
if (second_diff != -1 && S[first_diff] == T[second_diff] && S[second_diff] == T[first_diff]) {
return "SWAP " + string(1, S[first_diff]) + " " + string(1, S[second_diff]);
}
}
return "IMPOSSIBLE";
}
Palo Alto โ
import java.util.HashMap;
class Solution {
public int solution(String S) {
int maxLength = 0;
for (int start = 0; start < S.length(); start++) {
HashMap<Character, Integer> charCount = new HashMap<>();
for (int end = start; end < S.length(); end++) {
char currentChar = S.charAt(end);
charCount.put(currentChar, charCount.getOrDefault(currentChar, 0) + 1);
if (allEven(charCount)) {
maxLength = Math.max(maxLength, end - start + 1);
}
}
}
return maxLength;
}
private boolean allEven(HashMap<Character, Integer> charCount) {
for (int count : charCount.values()) {
if (count % 2 != 0) {
return false;
}
}
return true;
}
Palo Alto โ
#include <iostream>
using namespace std;
class TreeNode {
public:
int x;
TreeNode* left;
TreeNode* right;
TreeNode(int value) : x(value), left(nullptr), right(nullptr) {}
};
class Solution {
public:
TreeNode* solution(TreeNode* T) {
if (!T) return nullptr;
if (!T->left && !T->right) {
TreeNode* newNode = new TreeNode(T->x);
newNode->left = new TreeNode(T->x);
newNode->right = new TreeNode(T->x);
return newNode;
}
if (T->left) {
T->left = solution(T->left);
}
if (T->right) {
T->right = solution(T->right);
}
return T;
}
};
public static int minStrength(int N, int M, int[][] strength, int[][] confidence) {
int left = 1, right = 1000000;
while (left < right) {
int mid = left + (right - left) / 2;
if (canCross(N, M, strength, confidence, mid)) {
right = mid;
} else {
left = mid + 1;
}
}
return left;
}
private static boolean canCross(int N, int M, int[][] strength, int[][] confidence, int initialStrength) {
int currentStrength = initialStrength;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (currentStrength < strength[i][j]) {
return false;
}
currentStrength += confidence[i][j];
}
}
return true;
}
Acolite โ
int left = 1, right = 1000000;
while (left < right) {
int mid = left + (right - left) / 2;
if (canCross(N, M, strength, confidence, mid)) {
right = mid;
} else {
left = mid + 1;
}
}
return left;
}
private static boolean canCross(int N, int M, int[][] strength, int[][] confidence, int initialStrength) {
int currentStrength = initialStrength;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (currentStrength < strength[i][j]) {
return false;
}
currentStrength += confidence[i][j];
}
}
return true;
}
Acolite โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Twilio Hiring SWE Interns
Batch: 3rd Year students or 2026 Batch
Apply
https://job-boards.greenhouse.io/twilio/jobs/6267229?gh_src=krishankumarlinkedin
Batch: 3rd Year students or 2026 Batch
Apply
https://job-boards.greenhouse.io/twilio/jobs/6267229?gh_src=krishankumarlinkedin
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string solve(string S) {
string protocol, hostname, fileName = "", result = "";
stringstream output;
size_t pos = S.find("://");
if (pos != string::npos) {
protocol = S.substr(0, pos);
}
string rest = S.substr(pos + 3);
pos = rest.find('/');
if (pos != string::npos) {
hostname = rest.substr(0, pos);
rest = rest.substr(pos + 1);
} else {
hostname = rest;
rest = "";
}
output << protocol << endl;
output << hostname << endl;
size_t queryPos = rest.find('?');
if (queryPos != string::npos) {
fileName = rest.substr(0, queryPos);
string query = rest.substr(queryPos + 1);
if (!fileName.empty()) {
output << fileName << endl;
}
output << "Query parameters:" << endl;
stringstream ss(query);
string item;
while (getline(ss, item, '&')) {
size_t equalPos = item.find('=');
if (equalPos != string::npos) {
string key = item.substr(0, equalPos);
string value = item.substr(equalPos + 1);
output << " " << key << ": " << value << endl;
}
}
} else if (!rest.empty()) {
output << rest << endl;
}
result = output.str();
return result;
}
URL Parser โ
Dunhunby
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Solventum hiring Quality Assurance Engineer
0-2 years experience
5-10 LPA CTC
Apply Here : https://healthcare.wd1.myworkdayjobs.com/Search/job/IN-Bangalore-Kar/Software-Quality-Test-Engineer---HIS--Bangalore-_R01109903?source=LinkedIn
0-2 years experience
5-10 LPA CTC
Apply Here : https://healthcare.wd1.myworkdayjobs.com/Search/job/IN-Bangalore-Kar/Software-Quality-Test-Engineer---HIS--Bangalore-_R01109903?source=LinkedIn
Myworkdayjobs
Software Quality Test Engineer - HIS (Bangalore)
Thank you for your interest in working for our Company. Recruiting the right talent is crucial to our goals. On April 1, 2024, 3M Healthcare underwent a corporate spin-off leading to the creation of a new company named Solventum. We are still in the processโฆ
#include <iostream>
#include <cmath>
using namespace std;
long long ss(long long n) {
long long sum = 0;
if (n % 2 == 0) {
sum += 2;
while (n % 2 == 0) {
n /= 2;
}
}
for (long long i = 3; i <= sqrt(n); i += 2) {
if (n % i == 0) {
sum += i;
while (n % i == 0) {
n /= i;
}
}
}
if (n > 1) {
sum += n;
}
return sum;
}
int main() {
long long n;
cin >> n;
cout << ss(n) << endl;
return 0;
}
Sum of prime factors โ
HSBC
SELECT l.id, l.title, l.rating, l.year
FROM library l
JOIN (
SELECT year, MAX(rating) AS max_rating
FROM library
GROUP BY year
) AS year_max
ON l.year = year_max.year AND l.rating = year_max.max_rating
ORDER BY l.year ASC;
Book of the year โ
FROM library l
JOIN (
SELECT year, MAX(rating) AS max_rating
FROM library
GROUP BY year
) AS year_max
ON l.year = year_max.year AND l.rating = year_max.max_rating
ORDER BY l.year ASC;
Book of the year โ
Best Grade โ
Barco (FTE)
Barco (FTE)