Accenture ONCAMPUS drive Help Available
@Mrtrueliving_ix @Mrtrueliving_ix
Test Clearance guarantee ❤️
https://t.me/Code_alphix/8592?single
31 oct 2025, 21:16
🚀 Placement Preparation Hub 🎓 From Preparation to Placement ⚡️ OA Support • Coding • Aptitude • Technical • HR 🌟 Trusted by Hundreds of Students 📩 DM: @Mrtrueliving_ix 💙 Turning Aspirations into Offer Letters.
Mostrar másTCS CodeVita Verified Codes 🔥📌 Many are posting codes — but there’s no guarantee they pass all test cases. ⚠️ Some face presentation or runtime errors. ✅ Only this page provides 100% accepted & verified codes! 💯 🧠 Avoid plagiarism — TCS checks for code similarity. 💡 Add a dummy loop or change structure to make it unique. 📲 Join here: https://t.me/Code_alphix ⏳ Don’t wait — share with your friends before it’s deleted! Spread to maximum people 🚀 #TCSCodeVita #CodeAlphix #PlacementPrep
from collections import defaultdict, deque
import sys
def f(n, nm, sk, fr, rv, cap):
idx = {x: i for i, x in enumerate(nm)}
p = list(range(n))
def fd(x):
while x != p[x]:
p[x] = p[p[x]]
x = p[x]
return x
def un(a, b):
ra, rb = fd(a), fd(b)
if ra != rb:
p[rb] = ra
for a, b in fr:
un(idx[a], idx[b])
gmap = defaultdict(list)
for i in range(n):
gmap[fd(i)].append(i)
gs = []
for v in gmap.values():
tot = sum(sk[i] for i in v)
gs.append((v, tot))
m = len(gs)
gid = {}
for i, (v, _) in enumerate(gs):
for x in v:
gid[x] = i
rg = defaultdict(set)
for a, b in rv:
ga, gb = gid[idx[a]], gid[idx[b]]
if ga != gb:
rg[ga].add(gb)
rg[gb].add(ga)
vis = [0]*m
comps = []
for i in range(m):
if not vis[i]:
q = deque([i])
vis[i] = 1
comp = []
while q:
u = q.popleft()
comp.append(u)
for v in rg[u]:
if not vis[v]:
vis[v] = 1
q.append(v)
comps.append(comp)
chs = []
for c in comps:
opt = []
k = len(c)
for mask in range(1<<k):
ts = tc = 0
ok = 1
for i in range(k):
if (mask>>i)&1:
for j in range(i+1,k):
if (mask>>j)&1 and c[j] in rg[c[i]]:
ok = 0
break
if not ok:
break
ts += gs[c[i]][1]
tc += len(gs[c[i]][0])
if ok and ts <= cap:
opt.append((ts, tc))
opt.sort()
flt = []
bp = 0
for s, p in opt:
if p > bp:
flt.append((s, p))
bp = p
chs.append(flt)
dp = [0]*(cap+1)
for opt in chs:
ndp = dp[:]
for s, p in opt:
for w in range(cap-s, -1, -1):
if dp[w]+p > ndp[w+s]:
ndp[w+s] = dp[w]+p
dp = ndp
return max(dp)
def main():
n = int(input().strip())
nm = input().strip().split()
sk = list(map(int, input().strip().split()))
nf = int(input().strip())
fr = [tuple(input().strip().split()) for _ in range(nf)]
nr = int(input().strip())
rv = [tuple(input().strip().split()) for _ in range(nr)]
cap = int(input().strip())
sys.stdout.write(str(f(n, nm, sk, fr, rv, cap)))
if __name__ == "__main__":
main()
Uno ✓ || @Mrtrueliving_ix - codevita ✓import java.io.*;
import java.util.*;
public class F1Logistics {
static class Race {
int x, y, d;
Race(int x, int y, int d) {
this.x = x;
this.y = y;
this.d = d;
}
}
static List<Integer>[] adj;
static int[] match;
static boolean[] vis;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
String s = br.readLine();
if (s == null || s.trim().isEmpty()) {
pw.print(0);
pw.flush();
return;
}
int n = Integer.parseInt(s.trim());
Race[] a = new Race[n];
for (int i = 0; i < n; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
a[i] = new Race(Integer.parseInt(st.nextToken()),
Integer.parseInt(st.nextToken()),
Integer.parseInt(st.nextToken()));
}
adj = new ArrayList[n];
for (int i = 0; i < n; i++) adj[i] = new ArrayList<>();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i == j) continue;
Race r1 = a[i], r2 = a[j];
if (r2.d > r1.d) {
long dist = Math.abs(r1.x - r2.x) + Math.abs(r1.y - r2.y);
if (r2.d - r1.d >= dist) adj[i].add(j);
}
}
}
match = new int[n];
Arrays.fill(match, -1);
int cnt = 0;
for (int i = 0; i < n; i++) {
vis = new boolean[n];
if (dfs(i)) cnt++;
}
pw.print(n - cnt);
pw.flush();
}
static boolean dfs(int u) {
for (int v : adj[u]) {
if (!vis[v]) {
vis[v] = true;
if (match[v] == -1 || dfs(match[v])) {
match[v] = u;
return true;
}
}
}
return false;
}
}
F1 ✓ @Mrtrueliving_ix || codevita ✓TCS codevita Help done ✅DM for any placement Help ✓ @Mrtrueliving_ix @Mrtrueliving_ix 4/ 6 Qs solved 🤗 || 💯 plagfree coding #TCS #codevita #Offcampus
import sys
from itertools import combinations
https://t.me/Code_alphix
input = sys.stdin.readline
n = int(input().strip())
a = []https://t.me/Code_alphix
for _ in range(n):
x1, y1, x2, y2 = map(int, input().split())
if x2 < x1: x1, x2 = x2, x1
if y2 < y1: y1, y2 = y2, y1
a.append((x1, y1, x2, y2))
ox1, oy1, ox2, oy2 = map(int, input().split())https://t.me/Code_alphix
if ox2 < ox1: ox1, ox2 = ox2, ox1
if oy2 < oy1: oy1, oy2 = oy2, oy1
https://t.me/Code_alphix
xs, ys = [], []
for x in range(ox1 + 1, ox2):
if all(not (r[0] < x < r[2]) for r in a):
xs.append(x)
https://t.me/Code_alphix
for y in range(oy1 + 1, oy2):
if all(not (r[1] < y < r[3]) for r in a):
ys.append(y)
mA = float('inf')https://t.me/Code_alphix
vx_all = [ox1] + xs + [ox2]
vy_all = [oy1] + ys + [oy2]
for mx in range(1 << len(xs)):
@code_alphix
vx = [ox1] + [xs[i] for i in range(len(xs)) if (mx >> i) & 1] + [ox2]
vx.sort()@code_alphix
for my in range(1 << len(ys)):
vy = [oy1] + [ys[j] for j in range(len(ys)) if (my >> j) & 1] + [oy2]
vy.sort()
for i in range(len(vx) - 1):
for j in range(len(vy) - 1):
ar = (vx[i + 1] - vx[i]) * (vy[j + 1] - vy[j])
if ar < mA:
mA = ar
https://t.me/Code_alphix
if mA == float('inf'):
mA = (ox2 - ox1) * (oy2 - oy1)
print(mA)
Smallest region ✓ || codevita ✓
@Mrtrueliving_ix @Mrtrueliving_iximport java.util.*;
https://t.me/Code_alphix
public class RasikhBox {
static void g(char[][] a) {
int r = a.length, c = a[0].length;
for (int i = 0; i < c; i++) {
int k = 0;
for (int j = 0; j < r; j++) if (a[j][i] == '*') k++;
for (int j = 0; j < r - k; j++) a[j][i] = '.';https://t.me/Code_alphix
for (int j = r - k; j < r; j++) a[j][i] = '*';
}
}
https://t.me/Code_alphix
static char[][] rr(char[][] a) {
int r = a.length, c = a[0].length;
char[][] b = new char[c][r];
for (int i = 0; i < c; i++)
for (int j = 0; j < r; j++)
b[i][j] = a[r - 1 - j][i];
return b;
}
https://t.me/Code_alphix
static char[][] lr(char[][] a) {
int r = a.length, c = a[0].length;
char[][] b = new char[c][r];
for (int i = 0; i < c; i++)
for (int j = 0; j < r; j++)
b[i][j] = a[j][c - 1 - i];
return b;
}
https://t.me/Code_alphix
public static void main(String[] x) {
Scanner s = new Scanner(System.in);
int p = s.nextInt(), q = s.nextInt();
char[][] a = new char[p][q];
for (int i = 0; i < p; i++)
for (int j = 0; j < q; j++)
a[i][j] = s.next().charAt(0);
int n = s.nextInt();
String[] o = new String[n];
for (int i = 0; i < n; i++) o[i] = s.next();
g(a);
for (String z : o) {
for (int d = 0; d < 1; d++);
if (z.equals("right")) a = rr(a);
else a = lr(a);
g(a);
}
int r = a.length, c = a[0].length;
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
System.out.print(a[i][j]);
if (j + 1 < c) System.out.print(" ");
}
if (i + 1 < r) System.out.println();
}
s.close();
}
}
Rishikbox ✓ TCS codevita ✓
💯 Plagfree ✓
Stay tuned for more more codes
https://t.me/Code_alphix
Utilizamos cookies para mejorar tu experiencia de navegación.
Al hacer clic en «Aceptar todo», aceptas la política de uso de cookies.