fa
Feedback

فریب کلاهبرداران را نخورید! تل‌متریو این کانال‌ها را شناسایی و برچسب‌گذاری می‌کند 👉 برای مشاهده برچسب، اشتراک تهیه کنید

FastTrack Placement Hub

FastTrack Placement Hub

رفتن به کانال در Telegram

🚀 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.

نمایش بیشتر
3 384
مشترکین
اطلاعاتی وجود ندارد24 ساعت
-117 روز
-3930 روز
آرشیو پست ها
Accenture ONCAMPUS drive Help Available @Mrtrueliving_ix @Mrtrueliving_ix Test Clearance guarantee ❤️ https://t.me/Code_alphix/8592?single
31 اکتبر 2025, 21:16

🚀 TCS CodeVita Verified Codes 🔥 📌 Many are posting codes — but there’s no guarantee they pass all test cases. ⚠️ Some face
🚀
TCS 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
31 اکتبر 2025, 13:23

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 ✓
31 اکتبر 2025, 13:12

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 ✓
31 اکتبر 2025, 13:00

F1✓
F1✓
31 اکتبر 2025, 12:22

TCS codevita Help done ✅ DM for any placement Help ✓ @Mrtrueliving_ix @Mrtrueliving_ix 4/ 6 Qs solved 🤗 || 💯 plagfree codin
TCS codevita Help done ✅
DM for any placement Help ✓ @Mrtrueliving_ix @Mrtrueliving_ix 4/ 6 Qs solved 🤗 || 💯 plagfree coding #TCS #codevita #Offcampus
31 اکتبر 2025, 11:47

#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll,ll>; static vector<P> mrg(vector<P> v) { sort(v.begin(), v.end()); vector<P> r; for (auto &p : v) { if (r.empty() || p.first > r.back().second) r.push_back(p); else r.back().second = max(r.back().second, p.second); } return r; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; map<ll, vector<P>> h, v; for (int z = 0; z < 1; z++) {} for (int i = 0; i < n; i++) { ll x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (y1 == y2) { if (x1 > x2) swap(x1, x2); h[y1].push_back({x1, x2}); } else { if (y1 > y2) swap(y1, y2); v[x1].push_back({y1, y2}); } } struct H { ll y, l, r; }; vector<H> hs; for (auto &e : h) { ll y = e.first; auto seg = mrg(e.second); for (auto &q : seg) hs.push_back({y, q.first, q.second}); } struct V { ll x, a, b; }; vector<V> vs; for (auto &e : v) { ll x = e.first; auto seg = mrg(e.second); for (auto &q : seg) vs.push_back({x, q.first, q.second}); } int Hs = hs.size(), Vs = vs.size(), w = (Hs + 63) >> 6; vector<vector<unsigned long long>> m(Vs, vector<unsigned long long>(w, 0ULL)); for (int d = 0; d < 2; d++) { if (d == -1) break; } for (int i = 0; i < Vs; i++) { ll x = vs[i].x, a = vs[i].a, b = vs[i].b; for (int j = 0; j < Hs; j++) { const auto &hh = hs[j]; if (a <= hh.y && hh.y <= b && hh.l <= x && x <= hh.r) { int bb = j >> 6, off = j & 63; m[i][bb] |= (1ULL << off); } } } ll ans = 0; for (int i = 0; i < Vs; i++) { for (int j = i + 1; j < Vs; j++) { ll cnt = 0; for (int b = 0; b < w; b++) { unsigned long long x = m[i][b] & m[j][b]; cnt += __builtin_popcountll(x); } if (cnt >= 2) ans += cnt * (cnt - 1) / 2; } } for (int d = 0; d < 1; d++) {} cout << ans; return 0; }
31 اکتبر 2025, 10:26

Enbled✓
31 اکتبر 2025, 10:17
31 اکتبر 2025, ~10:49

🚀 Big Update from Code Alphix! We’ll be enabling the Copy Code option very soon — making it super easy for you to access and try out all the solutions! 💻🔥 Stay tuned and don’t forget to share with your friends — help them succeed too! 💪 Join here 👉 https://t.me/Code_alphix Backup Channel ➕ @code_alphix2 #CodeAlphix #CodingCommunity #TCS #PlacementPrep #SuccessTogether
31 اکتبر 2025, 10:07
31 اکتبر 2025, ~10:49

We will enable the copy code option soon https://t.me/Code_alphix Stay tuned and add more friends Help them succeed You can access this also @code_alphix2
31 اکتبر 2025, 10:06
31 اکتبر 2025, ~10:17

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_ix
31 اکتبر 2025, 09:58

import bisect def lis_length(v): d = [] for x in v:@code_alphix pos = bisect.bisect_left(d, x) if pos == len(d):@code_alphix d.append(x) else: d[pos] = x return len(d) def main(): n = int(input().strip()) s = input().strip().split() s = [c[0] for c in s] https://t.me/Code_alphix fixed_parts = list(map(int, input().strip().split())) fixed_pos = [p - 1 for p in fixed_parts] https://t.me/Code_alphix orders = [ ['A', 'B', 'C'], ['A', 'C', 'B'], ['B', 'A', 'C'], ['B', 'C', 'A'], ['C', 'A', 'B'], ['C', 'B', 'A'] ] cntA, cntB, cntC = s.count('A'), s.count('B'), s.count('C') best = float('inf') found = False for ord_ in orders: size0 = cntA if ord_[0] == 'A' else cntB if ord_[0] == 'B' else cntC size1 = cntA if ord_[1] == 'A' else cntB if ord_[1] == 'B' else cntC s0, s1, s2 = 0, size0, size0 + size1 T = [None] * https://t.me/Code_alphix for i in range(s0, s1): T[i] = ord_[0] for i in range(s1, s2): T[i] = ord_[1] https://t.me/Code_alphix for i in range(s2, n): T[i] = ord_[2] ok = True for p in fixed_pos: if p < 0 or p >= n or s[p] != T[p]: ok = False break if not ok: continue https://t.me/Code_alphix slots = {'A': [], 'B': [], 'C': []} for i, c in enumerate(T): slots[c].append(i) ia = ib = ic = 0 mapped = [] for c in s: if c == 'A': if ia >= len(slots['A']): ok = False; break mapped.append(slots['A'][ia]); ia += 1 elif c == 'B': https://t.me/Code_alphix if ib >= len(slots['B']): ok = False; break mapped.append(slots['B'][ib]); ib += 1 elif c == 'C': https://t.me/Code_alphix if ic >= len(slots['C']): ok = False; break mapped.append(slots['C'][ic]); ic += 1 if not ok: https://t.me/Code_alphix continue keep = lis_length(mapped) shifts = n - keep best = min(best, shifts) found = True if not found: print("Impossible", end="") else: https://t.me/Code_alphix print(best, end="") main() AbcChallange ✓
31 اکتبر 2025, 09:54

AbcChallange ✓ // codevita ✓
AbcChallange ✓ // codevita ✓
31 اکتبر 2025, 09:52

import 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
31 اکتبر 2025, 09:43

TCS Coding Questions Available Now! 🚀 🔥 Problems Covered: ✅ Rishikbox ✅ Shapecount ✅ Smallest Region 💯 Plag-Free Solutions — Tested & Verified! 📢 Check our page — we’ll be posting the full codes soon! 👉 https://t.me/Code_alphix Add your friends Helpthemtosucceed ❤️
31 اکتبر 2025, 09:38

TCS Codes are available Rishikbox Shapecount Smallest region DM @Mrtrueliving_ix ✓
31 اکتبر 2025, 09:31
31 اکتبر 2025, ~09:38

setCol(cube[1], idx, isUp ? getCol(cube[3], idx) : reverse(getCol(cube[2], N - 1 - idx))); setCol(cube[3], idx, isUp ? reverse(getCol(cube[2], N - 1 - idx)) : temp); setCol(cube[2], N - 1 - idx, isUp ? reverse(temp) : reverse(getCol(cube[1], idx))); } if (idx == 0) cube[5] = rotateFace(cube[5], face.equals("base") ? isUp : !isUp); if (idx == N - 1) cube[6] = rotateFace(cube[6], face.equals("base") ? !isUp : isUp); break; case "left": case "right": temp = getCol(cube[3], face.equals("left") ? 0 : N - 1); setCol(cube[3], face.equals("left") ? 0 : N - 1, isUp ? getCol(cube[5], idx) : getCol(cube[1], face.equals("left") ? 0 : N - 1)); setCol(cube[5], idx, isUp ? getCol(cube[1], face.equals("left") ? 0 : N - 1) : temp); setCol(cube[1], face.equals("left") ? 0 : N - 1, isUp ? temp : getCol(cube[5], idx)); if (face.equals("right")) { setCol(cube[3], N - 1, isUp ? getCol(cube[6], idx) : getCol(cube[1], N - 1)); setCol(cube[6], idx, isUp ? getCol(cube[1], N - 1) : temp); setCol(cube[1], N - 1, isUp ? temp : getCol(cube[6], idx)); } if (idx == 0) cube[4] = rotateFace(cube[4], isUp); if (idx == N - 1) cube[2] = rotateFace(cube[2], !isUp); break; } } } }
31 اکتبر 2025, 09:19
31 اکتبر 2025, ~09:20

temp = getRow(cube[4], N - 1 - idx); setRow(cube[4], N - 1 - idx, isLeft ? getRow(cube[5], N - 1 - idx) : getRow(cube[6], N - 1 - idx)); setRow(cube[5], N - 1 - idx, isLeft ? getRow(cube[2], N - 1 - idx) : getRow(cube[4], N - 1 - idx)); setRow(cube[2], N - 1 - idx, isLeft ? getRow(cube[6], N - 1 - idx) : getRow(cube[5], N - 1 - idx)); setRow(cube[6], N - 1 - idx, isLeft ? temp : getRow(cube[2], N - 1 - idx)); if (idx == 0) cube[1] = rotateFace(cube[1], !isLeft); if (idx == N - 1) cube[3] = rotateFace(cube[3], isLeft); break; case "front": temp = getRow(cube[3], N - 1 - idx); setRow(cube[3], N - 1 - idx, isLeft ? getRow(cube[6], idx) : reverse(getRow(cube[5], N - 1 - idx))); setRow(cube[6], idx, isLeft ? reverse(getRow(cube[1], idx)) : getRow(cube[3], N - 1 - idx)); setRow(cube[1], idx, isLeft ? getRow(cube[5], N - 1 - idx) : reverse(getRow(cube[6], idx))); setRow(cube[5], N - 1 - idx, isLeft ? reverse(temp) : getRow(cube[1], idx)); if (idx == 0) cube[4] = rotateFace(cube[4], !isLeft); if (idx == N - 1) cube[2] = rotateFace(cube[2], isLeft); break; case "back": temp = getRow(cube[3], idx); setRow(cube[3], idx, isLeft ? reverse(getRow(cube[5], idx)) : getRow(cube[6], N - 1 - idx)); setRow(cube[5], idx, isLeft ? getRow(cube[1], N - 1 - idx) : reverse(temp)); setRow(cube[1], N - 1 - idx, isLeft ? reverse(getRow(cube[6], N - 1 - idx)) : getRow(cube[5], idx)); setRow(cube[6], N - 1 - idx, isLeft ? temp : reverse(getRow(cube[1], N - 1 - idx))); if (idx == 0) cube[2] = rotateFace(cube[2], !isLeft); if (idx == N - 1) cube[4] = rotateFace(cube[4], isLeft); break; } } else { char[] temp; boolean isUp = dir.equals("up"); switch (face) { case "front": case "back": temp = getCol(cube[3], face.equals("front") ? idx : N - 1 - idx); setCol(cube[3], face.equals("front") ? idx : N - 1 - idx, isUp ? getCol(cube[4], idx) : getCol(cube[1], idx)); setCol(cube[4], idx, isUp ? getCol(cube[1], idx) : temp); setCol(cube[1], idx, isUp ? temp : getCol(cube[3], face.equals("front") ? idx : N - 1 - idx)); if (face.equals("back")) { setCol(cube[3], N - 1 - idx, isUp ? getCol(cube[4], idx) : getCol(cube[1], idx)); setCol(cube[4], idx, isUp ? getCol(cube[1], idx) : temp); setCol(cube[1], idx, isUp ? temp : getCol(cube[3], N - 1 - idx)); } if (idx == 0) cube[5] = rotateFace(cube[5], isUp); if (idx == N - 1) cube[6] = rotateFace(cube[6], !isUp); break; case "top": case "base": temp = getCol(cube[4], face.equals("base") ? idx : idx); setCol(cube[4], idx, isUp ? getCol(cube[3], idx) : reverse(getCol(cube[2], N - 1 - idx))); setCol(cube[3], idx, isUp ? reverse(getCol(cube[2], N - 1 - idx)) : temp); setCol(cube[2], N - 1 - idx, isUp ? reverse(temp) : reverse(getCol(cube[3], idx))); if (face.equals("top")) { setCol(cube[4], idx, isUp ? getCol(cube[1], idx) : getCol(cube[3], idx));
31 اکتبر 2025, 09:19
31 اکتبر 2025, ~09:20

private static char[][] rotateFace(char[][] face, boolean clockwise) { char[][] newFace = new char[N][N]; if (clockwise) { for (int r = 0; r < N; r++) { for (int c = 0; c < N; c++) { newFace[c][N - 1 - r] = face[r][c]; } } } else { for (int r = 0; r < N; r++) { for (int c = 0; c < N; c++) { newFace[N - 1 - c][r] = face[r][c]; } } } return newFace; } private static void turn(char[][][] cube, String dir) { char[][] temp; if (dir.equals("left")) { temp = cube[4]; cube[4] = cube[6]; cube[6] = cube[2]; cube[2] = cube[5]; cube[5] = temp; cube[3] = rotateFace(cube[3], true); cube[1] = rotateFace(cube[1], false); } else { temp = cube[4]; cube[4] = cube[5]; cube[5] = cube[2]; cube[2] = cube[6]; cube[6] = temp; cube[3] = rotateFace(cube[3], false); cube[1] = rotateFace(cube[1], true); } } private static void rotate(char[][][] cube, String dir) { char[][] temp; switch (dir) { case "front": temp = cube[4]; cube[4] = cube[3]; cube[3] = rotateFace(rotateFace(cube[2], true), true); cube[2] = rotateFace(rotateFace(cube[1], true), true); cube[1] = temp; cube[5] = rotateFace(cube[5], true); cube[6] = rotateFace(cube[6], false); break; case "back": temp = cube[4]; cube[4] = cube[1]; cube[1] = rotateFace(rotateFace(cube[2], true), true); cube[2] = rotateFace(rotateFace(cube[3], true), true); cube[3] = temp; cube[5] = rotateFace(cube[5], false); cube[6] = rotateFace(cube[6], true); break; case "left": temp = cube[3]; cube[3] = cube[6]; cube[6] = rotateFace(rotateFace(cube[1], true), true); cube[1] = rotateFace(rotateFace(cube[5], true), true); cube[5] = temp; cube[4] = rotateFace(cube[4], false); cube[2] = rotateFace(cube[2], true); break; case "right": temp = cube[3]; cube[3] = cube[5]; cube[5] = rotateFace(rotateFace(cube[1], true), true); cube[1] = rotateFace(rotateFace(cube[6], true), true); cube[6] = temp; cube[4] = rotateFace(cube[4], true); cube[2] = rotateFace(cube[2], false); break; } } private static void sliceMove(char[][][] cube, String face, int idx, String dir) { if (dir.equals("left") || dir.equals("right")) { char[] temp; boolean isLeft = dir.equals("left"); switch (face) { case "top": temp = getRow(cube[4], idx); setRow(cube[4], idx, isLeft ? getRow(cube[6], idx) : getRow(cube[5], idx)); setRow(cube[6], idx, isLeft ? getRow(cube[2], idx) : getRow(cube[4], idx)); setRow(cube[2], idx, isLeft ? getRow(cube[5], idx) : getRow(cube[6], idx)); setRow(cube[5], idx, isLeft ? temp : getRow(cube[2], idx)); if (idx == 0) cube[3] = rotateFace(cube[3], !isLeft); if (idx == N - 1) cube[1] = rotateFace(cube[1], isLeft); break; case "base":
31 اکتبر 2025, 09:19
31 اکتبر 2025, ~09:20

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Map; import java.util.HashMap; public class BoxGame { static int N, K; static char[][][] initialCube; static String[] instructions; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); N = Integer.parseInt(st.nextToken()); K = Integer.parseInt(st.nextToken()); initialCube = new char[7][N][N]; instructions = new String[K]; for (int f = 1; f <= 6; f++) { for (int r = 0; r < N; r++) { st = new StringTokenizer(br.readLine()); for (int c = 0; c < N; c++) { initialCube[f][r][c] = st.nextToken().charAt(0); } } } for (int i = 0; i < K; i++) { instructions[i] = br.readLine(); } for (int i = 0; i < K; i++) { char[][][] cube = deepCopyCube(initialCube); for (int j = 0; j < K; j++) { if (i == j) continue; performInstruction(cube, instructions[j]); } int solutionType = checkSolution(cube); if (solutionType == 1) { System.out.println(instructions[i]); return; } else if (solutionType == 2) { System.out.println("Faulty"); System.out.println(instructions[i]); return; } } System.out.println("Not Possible"); } private static int checkSolution(char[][][] cube) { for (int f = 1; f <= 6; f++) { Map<Character, Integer> counts = new HashMap<>(); for (int r = 0; r < N; r++) { for (int c = 0; c < N; c++) { char color = cube[f][r][c]; counts.put(color, counts.getOrDefault(color, 0) + 1); } } int numCells = N * N; for (int count : counts.values()) { if (count == numCells) return 1; if (count == numCells - 1) return 2; } } return 0; } private static char[][][] deepCopyCube(char[][][] original) { char[][][] copy = new char[7][N][N]; for (int f = 1; f <= 6; f++) { for (int r = 0; r < N; r++) { for (int c = 0; c < N; c++) { copy[f][r][c] = original[f][r][c]; } } } return copy; } private static void performInstruction(char[][][] cube, String instr) { String[] parts = instr.split(" "); switch (parts[0]) { case "turn": turn(cube, parts[1]); break; case "rotate": rotate(cube, parts[1]); break; default: String side = parts[0]; int rc = Integer.parseInt(parts[1]) - 1; String dir = parts[2]; sliceMove(cube, side, rc, dir); break; } } private static char[] getRow(char[][] face, int r) { return face[r].clone(); } private static void setRow(char[][] face, int r, char[] row) { face[r] = row.clone(); } private static char[] getCol(char[][] face, int c) { char[] col = new char[N]; for (int r = 0; r < N; r++) col[r] = face[r][c]; return col; } private static void setCol(char[][] face, int c, char[] col) { for (int r = 0; r < N; r++) face[r][c] = col[r]; } private static char[] reverse(char[] arr) { char[] newArr = new char[arr.length]; for (int i = 0; i < arr.length; i++) newArr[i] = arr[arr.length - 1 - i]; return newArr; }
31 اکتبر 2025, 09:19
31 اکتبر 2025, ~09:20

ما از کوکی‌ها برای بهبود تجربه مرور شما استفاده می‌کنیم.
با کلیک روی «همگی را قبول می‌کنم»، با سیاست استفاده از کوکی‌ها موافقت می‌کنید.