fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. }
  14. }
Success #stdin #stdout 0.08s 54516KB
stdin
import React, { useEffect, useMemo, useRef, useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { Shuffle, Trophy, Sparkles, Volume2, VolumeX, Flame, Shield, Star, Repeat2, Gift, Wand2, Lock, Share2, Heart, History, BadgeInfo, Megaphone, } from "lucide-react";

const CLUBS = [ { id: "mci", name: "Manchester City", type: "club", league: "Premier League", region: "Europe", strength: 95, logo: "🔵", colors: "from-sky-500 to-blue-700" }, { id: "liv", name: "Liverpool", type: "club", league: "Premier League", region: "Europe", strength: 92, logo: "🔴", colors: "from-red-500 to-rose-700" }, { id: "ars", name: "Arsenal", type: "club", league: "Premier League", region: "Europe", strength: 90, logo: "🔴", colors: "from-rose-500 to-orange-600" }, { id: "rma", name: "Real Madrid", type: "club", league: "La Liga", region: "Europe", strength: 96, logo: "👑", colors: "from-zinc-100 to-zinc-400" }, { id: "bar", name: "FC Barcelona", type: "club", league: "La Liga", region: "Europe", strength: 94, logo: "🔵", colors: "from-blue-600 to-red-600" }, { id: "atm", name: "Atlético Madrid", type: "club", league: "La Liga", region: "Europe", strength: 89, logo: "⚪", colors: "from-red-700 to-slate-900" }, { id: "juv", name: "Juventus", type: "club", league: "Serie A", region: "Europe", strength: 88, logo: "⚫", colors: "from-slate-900 to-slate-700" }, { id: "mil", name: "AC Milan", type: "club", league: "Serie A", region: "Europe", strength: 89, logo: "🔴", colors: "from-red-600 to-black" }, { id: "int", name: "Inter", type: "club", league: "Serie A", region: "Europe", strength: 91, logo: "🔵", colors: "from-sky-700 to-black" }, { id: "bvb", name: "Borussia Dortmund", type: "club", league: "Bundesliga", region: "Europe", strength: 87, logo: "🟡", colors: "from-yellow-400 to-black" }, { id: "bay", name: "Bayern Munich", type: "club", league: "Bundesliga", region: "Europe", strength: 95, logo: "🔴", colors: "from-red-600 to-rose-800" }, { id: "psg", name: "PSG", type: "club", league: "Ligue 1", region: "Europe", strength: 93, logo: "🔵", colors: "from-blue-800 to-pink-600" }, { id: "mon", name: "Monaco", type: "club", league: "Ligue 1", region: "Europe", strength: 84, logo: "🔴", colors: "from-red-600 to-white" }, { id: "por", name: "FC Porto", type: "club", league: "Primeira Liga", region: "Europe", strength: 85, logo: "🐉", colors: "from-blue-700 to-sky-400" }, { id: "aja", name: "Ajax", type: "club", league: "Eredivisie", region: "Europe", strength: 83, logo: "⭐", colors: "from-red-500 to-white" }, { id: "aln", name: "Al Nassr", type: "club", league: "Saudi Pro League", region: "Asia", strength: 84, logo: "🟡", colors: "from-yellow-400 to-amber-700" }, { id: "hil", name: "Al Hilal", type: "club", league: "Saudi Pro League", region: "Asia", strength: 86, logo: "🔷", colors: "from-sky-500 to-blue-900" }, { id: "Uls", name: "Ulsan HD", type: "club", league: "K League", region: "Asia", strength: 78, logo: "🟦", colors: "from-blue-500 to-slate-800" }, { id: "bfc", name: "Beijing Guoan", type: "club", league: "Chinese Super League", region: "Asia", strength: 76, logo: "🟩", colors: "from-emerald-500 to-green-800" }, { id: "san", name: "Santos", type: "club", league: "Brasileirão", region: "South America", strength: 79, logo: "⚪", colors: "from-white to-black" }, { id: "pal", name: "Palmeiras", type: "club", league: "Brasileirão", region: "South America", strength: 87, logo: "🟢", colors: "from-emerald-500 to-green-900" }, { id: "rio", name: "River Plate", type: "club", league: "Liga Argentina", region: "South America", strength: 88, logo: "🔴", colors: "from-red-600 to-white" }, { id: "boo", name: "Boca Juniors", type: "club", league: "Liga Argentina", region: "South America", strength: 86, logo: "💙", colors: "from-blue-700 to-yellow-400" }, { id: "afr1", name: "Al Ahly", type: "club", league: "Egypt Premier League", region: "Africa", strength: 80, logo: "🟥", colors: "from-red-700 to-amber-700" }, { id: "afr2", name: "Wydad AC", type: "club", league: "Botola Pro", region: "Africa", strength: 77, logo: "⬛", colors: "from-red-800 to-black" }, { id: "gal", name: "Galatasaray", type: "club", league: "Süper Lig", region: "Europe", strength: 84, logo: "🟠", colors: "from-orange-500 to-red-700" }, { id: "new", name: "Newcastle United", type: "club", league: "Premier League", region: "Europe", strength: 83, logo: "⚫", colors: "from-zinc-900 to-emerald-700" }, ];

const NATIONALS = [ { id: "fra", name: "France", type: "national", league: "National Team", region: "Europe", strength: 95, logo: "🇫🇷", colors: "from-blue-700 to-red-600" }, { id: "spa", name: "Spain", type: "national", league: "National Team", region: "Europe", strength: 91, logo: "🇪🇸", colors: "from-red-600 to-yellow-400" }, { id: "ger", name: "Germany", type: "national", league: "National Team", region: "Europe", strength: 90, logo: "🇩🇪", colors: "from-black to-red-600" }, { id: "ita", name: "Italy", type: "national", league: "National Team", region: "Europe", strength: 89, logo: "🇮🇹", colors: "from-green-600 to-blue-600" }, { id: "eng", name: "England", type: "national", league: "National Team", region: "Europe", strength: 90, logo: "🏴", colors: "from-slate-800 to-slate-500" }, { id: "porN", name: "Portugal", type: "national", league: "National Team", region: "Europe", strength: 88, logo: "🇵🇹", colors: "from-emerald-600 to-red-700" }, { id: "jpn", name: "Japan", type: "national", league: "National Team", region: "Asia", strength: 85, logo: "🇯🇵", colors: "from-rose-500 to-white" }, { id: "kor", name: "South Korea", type: "national", league: "National Team", region: "Asia", strength: 84, logo: "🇰🇷", colors: "from-red-600 to-sky-600" }, { id: "sau", name: "Saudi Arabia", type: "national", league: "National Team", region: "Asia", strength: 79, logo: "🇸🇦", colors: "from-green-700 to-emerald-500" }, { id: "aus", name: "Australia", type: "national", league: "National Team", region: "Asia", strength: 78, logo: "🇦🇺", colors: "from-sky-700 to-amber-500" }, { id: "nga", name: "Nigeria", type: "national", league: "National Team", region: "Africa", strength: 82, logo: "🇳🇬", colors: "from-green-700 to-black" }, { id: "mar", name: "Morocco", type: "national", league: "National Team", region: "Africa", strength: 84, logo: "🇲🇦", colors: "from-red-700 to-green-700" }, { id: "gha", name: "Ghana", type: "national", league: "National Team", region: "Africa", strength: 78, logo: "🇬🇭", colors: "from-red-600 to-green-600" }, { id: "sen", name: "Senegal", type: "national", league: "National Team", region: "Africa", strength: 81, logo: "🇸🇳", colors: "from-green-700 to-yellow-400" }, { id: "bra", name: "Brazil", type: "national", league: "National Team", region: "South America", strength: 94, logo: "🇧🇷", colors: "from-emerald-500 to-yellow-400" }, { id: "arg", name: "Argentina", type: "national", league: "National Team", region: "South America", strength: 93, logo: "🇦🇷", colors: "from-sky-500 to-white" }, { id: "uru", name: "Uruguay", type: "national", league: "National Team", region: "South America", strength: 87, logo: "🇺🇾", colors: "from-sky-600 to-white" }, { id: "col", name: "Colombia", type: "national", league: "National Team", region: "South America", strength: 84, logo: "🇨🇴", colors: "from-yellow-400 to-red-600" }, { id: "mex", name: "Mexico", type: "national", league: "National Team", region: "North America", strength: 82, logo: "🇲🇽", colors: "from-green-700 to-red-700" }, { id: "usa", name: "USA", type: "national", league: "National Team", region: "North America", strength: 83, logo: "🇺🇸", colors: "from-blue-700 to-red-700" }, ];

const LEAGUES = [ "Premier League", "La Liga", "Serie A", "Bundesliga", "Ligue 1", "Primeira Liga", "Eredivisie", "Saudi Pro League", "K League", "Chinese Super League", "Brasileirão", "Liga Argentina", "Egypt Premier League", "Botola Pro", "Süper Lig", ];

const NATIONAL_REGIONS = ["Europe", "Asia", "Africa", "North America", "South America"];

const EFFECTS = [ { id: "wheel", label: "Vòng quay may mắn", icon: "🎡" }, { id: "cards", label: "Bốc lá bài", icon: "🃏" }, { id: "gift", label: "Bốc hộp quà", icon: "🎁" }, { id: "flip", label: "Lật thẻ", icon: "🪙" }, ];

const SPECIAL_CARDS = [ { id: "opponent", label: "Chọn đội cho đối phương", icon: <Megaphone className="h-4 w-4" /> }, { id: "swap", label: "Đổi đội", icon: <Repeat2 className="h-4 w-4" /> }, { id: "strongWeak", label: "Chọn đội mạnh/yếu", icon: <Flame className="h-4 w-4" /> }, { id: "reroll", label: "Random lại", icon: <Shuffle className="h-4 w-4" /> }, { id: "extra", label: "Bốc thêm 1 lượt", icon: <Gift className="h-4 w-4" /> }, { id: "banLeague", label: "Cấm chọn một giải đấu", icon: <Lock className="h-4 w-4" /> }, ];

function clamp(min, max, value) { return Math.max(min, Math.min(max, value)); }

function pickRandom(arr) { return arr[Math.floor(Math.random() * arr.length)]; }

function shuffle(arr) { return [...arr].sort(() => Math.random() - 0.5); }

function getDataset(mode) { if (mode === "national") return NATIONALS; if (mode === "favorites") return [...CLUBS, ...NATIONALS]; return CLUBS; }

function normalize(str) { return String(str || "").toLowerCase(); }

function useLocalStorage(key, initialValue) { const [value, setValue] = useState(() => { if (typeof window === "undefined") return initialValue; try { const saved = window.localStorage.getItem(key); return saved ? JSON.parse(saved) : initialValue; } catch { return initialValue; } });

useEffect(() => { try { window.localStorage.setItem(key, JSON.stringify(value)); } catch { // ignore } }, [key, value]);

return [value, setValue]; }

function makeConfetti(count = 48) { return Array.from({ length: count }).map((_, i) => ({ id: ${Date.now()}-${i}, left: Math.random() * 100, delay: Math.random() * 0.35, size: 8 + Math.random() * 12, rotate: Math.random() * 360, duration: 1.8 + Math.random() * 1.8, })); }

function strengthLabel(n) { if (n >= 92) return "Elite"; if (n >= 87) return "Mạnh"; if (n >= 80) return "Tốt"; if (n >= 72) return "Khá"; return "Vui"; }

function playBeep(type = "win") { try { const AudioCtx = window.AudioContext || window.webkitAudioContext; if (!AudioCtx) return; const ctx = new AudioCtx(); const now = ctx.currentTime; const tones = type === "win" ? [392, 523.25, 659.25] : [220, 277.18]; tones.forEach((freq, idx) => { const osc = ctx.createOscillator(); const gain = ctx.createGain(); osc.type = "sine"; osc.frequency.value = freq; gain.gain.value = 0.0001; osc.connect(gain); gain.connect(ctx.destination); osc.start(now + idx * 0.08); gain.gain.exponentialRampToValueAtTime(0.2, now + idx * 0.08 + 0.01); gain.gain.exponentialRampToValueAtTime(0.0001, now + idx * 0.08 + 0.22); osc.stop(now + idx * 0.08 + 0.24); }); setTimeout(() => ctx.close().catch(() => {}), 1000); } catch { // ignore audio errors } }

function Card({ title, icon, children, className = "" }) { return ( <div className={rounded-3xl border border-white/10 bg-white/5 backdrop-blur-xl shadow-2xl shadow-black/20 ${className}}> <div className="flex items-center gap-2 border-b border-white/10 px-4 py-3 text-white/90"> <div className="rounded-2xl bg-white/10 p-2">{icon}</div> <h3 className="font-semibold">{title}</h3> </div> <div className="p-4">{children}</div> </div> ); }

function TeamChip({ team, onToggleFavorite, favorite }) { return ( <div className={rounded-2xl border border-white/10 bg-gradient-to-br ${team.colors} p-[1px]}> <div className="rounded-2xl bg-slate-950/90 p-3 text-white"> <div className="flex items-start justify-between gap-3"> <div> <div className="text-2xl">{team.logo}</div> <div className="mt-2 font-semibold leading-tight">{team.name}</div> <div className="mt-1 text-xs text-white/65">{team.type === "club" ? team.league : team.region} · {strengthLabel(team.strength)}</div> </div> <button onClick={() => onToggleFavorite(team.id)} className={rounded-full p-2 transition ${favorite ? "bg-pink-500/20 text-pink-300" : "bg-white/8 text-white/60 hover:bg-white/12"}} aria-label="favorite" > <Heart className={h-4 w-4 ${favorite ? "fill-pink-400" : ""}} /> </button> </div> </div> </div> ); }

export default function PesRandomizerWebsite() { const [mode, setMode] = useState("2p"); const [effect, setEffect] = useState("wheel"); const [soundOn, setSoundOn] = useState(true); const [partyMode, setPartyMode] = useState(true); const [uniqueTeams, setUniqueTeams] = useState(true); const [selectedLeague, setSelectedLeague] = useState("All"); const [selectedRegion, setSelectedRegion] = useState("All"); const [bannedLeague, setBannedLeague] = useState("None"); const [favoriteIds, setFavoriteIds] = useLocalStorage("pes-favorites", ["mci", "rma", "bar", "fra", "arg", "bra"]); const [history, setHistory] = useLocalStorage("pes-history", []); const [result, setResult] = useState(null); const [confetti, setConfetti] = useState([]); const [animating, setAnimating] = useState(false); const [specialCard, setSpecialCard] = useState(null); const [forcedMode, setForcedMode] = useState(null); const [partyMessage, setPartyMessage] = useState("Sẵn sàng random chưa? Nhấn nút lớn bên dưới!"); const resultRef = useRef(null);

const allTeams = useMemo(() => { if (mode === "national") return NATIONALS; if (mode === "favorites") { const fav = [...CLUBS, ...NATIONALS].filter((t) => favoriteIds.includes(t.id)); return fav.length ? fav : [...CLUBS, ...NATIONALS]; } return CLUBS; }, [mode, favoriteIds]);

const filteredTeams = useMemo(() => { let list = [...allTeams]; if (mode === "club" || mode === "2p" || mode === "party") { if (selectedLeague !== "All") list = list.filter((t) => t.type === "club" && t.league === selectedLeague); if (bannedLeague !== "None") list = list.filter((t) => t.league !== bannedLeague); } if (mode === "national") { if (selectedRegion !== "All") list = list.filter((t) => t.region === selectedRegion); } if (forcedMode === "strong") list = [...list].sort((a, b) => b.strength - a.strength); if (forcedMode === "weak") list = [...list].sort((a, b) => a.strength - b.strength); return list; }, [allTeams, mode, selectedLeague, selectedRegion, bannedLeague, forcedMode]);

const favoriteTeams = useMemo(() => [...CLUBS, ...NATIONALS].filter((t) => favoriteIds.includes(t.id)), [favoriteIds]);

const stats = useMemo(() => { const leagues = new Set(filteredTeams.filter((t) => t.type === "club").map((t) => t.league)); const regions = new Set(filteredTeams.filter((t) => t.type === "national").map((t) => t.region)); return { teams: filteredTeams.length, leagues: leagues.size, regions: regions.size }; }, [filteredTeams]);

useEffect(() => { if (resultRef.current && result) { resultRef.current.scrollIntoView({ behavior: "smooth", block: "center" }); } }, [result]);

function saveHistory(entry) { setHistory((prev) => [entry, ...prev].slice(0, 8)); }

function toggleFavorite(id) { setFavoriteIds((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [id, ...prev].slice(0, 18) ); }

function announce(text) { setPartyMessage(text); }

function chooseWithConstraints(source, { different = true } = {}) { if (!source.length) return null; const pool = shuffle(source); return pool[0] || null; }

function pickTwoTeams(source) { if (!source.length) return null; const pool = [...source]; if (pool.length === 1) { return uniqueTeams ? null : { a: pool[0], b: pool[0] }; }

const a = pickRandom(pool);
let remaining = pool.filter((t) => t.id !== a.id);
if (!uniqueTeams && Math.random() > 0.7) remaining = [...pool];
const b = remaining.length ? pickRandom(remaining) : null;
return b ? { a, b } : null;

}

function runRandom({ fromSpecial = false } = {}) { const source = filteredTeams; if (!source.length) { setResult({ error: "Không có đội nào phù hợp với bộ lọc hiện tại." }); return; }

setAnimating(true);
setResult(null);
if (soundOn) playBeep("spin");

const delay = effect === "wheel" ? 1050 : effect === "gift" ? 900 : effect === "cards" ? 780 : 680;
setTimeout(() => {
  let nextResult;
  if (mode === "2p" || mode === "party") {
    const picked = pickTwoTeams(source);
    if (!picked) {
      nextResult = { error: uniqueTeams ? "Danh sách hiện tại không đủ đội để chọn 2 đội khác nhau." : "Không thể random." };
    } else {
      nextResult = { type: "pair", a: picked.a, b: picked.b };
    }
  } else if (mode === "national") {
    nextResult = { type: "single", a: chooseWithConstraints(source) };
  } else if (mode === "favorites") {
    const picked = pickTwoTeams(source);
    nextResult = picked ? { type: "pair", a: picked.a, b: picked.b } : { error: "Danh sách yêu thích quá ít để random." };
  } else {
    const picked = pickTwoTeams(source);
    nextResult = picked ? { type: "pair", a: picked.a, b: picked.b } : { error: "Không đủ dữ liệu." };
  }

  if (nextResult?.error) {
    setResult(nextResult);
    announce(nextResult.error);
    setAnimating(false);
    return;
  }

  if (partyMode && mode === "party" && !fromSpecial) {
    const partyRoll = Math.random();
    if (partyRoll < 0.2) {
      setSpecialCard({ id: "opponent", label: "Thẻ đặc biệt: Chọn đội cho đối phương" });
      announce("Party mode: đối phương bị chọn đội bất ngờ!");
    } else if (partyRoll < 0.35) {
      setSpecialCard({ id: "strongWeak", label: "Thẻ đặc biệt: Chọn đội mạnh/yếu" });
    } else if (partyRoll < 0.48) {
      setSpecialCard({ id: "extra", label: "Thẻ đặc biệt: Bốc thêm 1 lượt" });
    } else if (partyRoll < 0.58) {
      setSpecialCard({ id: "swap", label: "Thẻ đặc biệt: Đổi đội" });
    } else {
      setSpecialCard(null);
    }
  }

  if (soundOn) playBeep("win");
  const entry = { ...nextResult, mode, effect, createdAt: new Date().toISOString() };
  setResult(nextResult);
  saveHistory(entry);
  setConfetti(makeConfetti(effect === "gift" ? 72 : 54));
  announce(
    nextResult.type === "pair"
      ? `${nextResult.a.name} vs ${nextResult.b.name}`
      : `Bạn nhận được ${nextResult.a.name}`
  );
  setAnimating(false);
  setTimeout(() => setConfetti([]), 2200);
}, delay);

}

function reroll() { runRandom({ fromSpecial: false }); }

function swapTeams() { if (!result || result.type !== "pair") return; setResult({ ...result, a: result.b, b: result.a }); const swapped = { ...result, a: result.b, b: result.a, createdAt: new Date().toISOString(), mode, effect }; saveHistory(swapped); setConfetti(makeConfetti(34)); if (soundOn) playBeep("win"); }

function chooseStrongWeak(kind) { const source = filteredTeams; if (!source.length) return; const ordered = [...source].sort((a, b) => (kind === "strong" ? b.strength - a.strength : a.strength - b.strength)); const top = ordered.slice(0, Math.max(2, Math.ceil(ordered.length * 0.3))); const picked = pickTwoTeams(top); if (!picked) return; setForcedMode(kind); setResult({ type: "pair", a: picked.a, b: picked.b }); saveHistory({ type: "pair", a: picked.a, b: picked.b, mode, effect, createdAt: new Date().toISOString(), special: kind }); setConfetti(makeConfetti(60)); announce(kind === "strong" ? "Đã chọn cặp đội mạnh!" : "Đã chọn cặp đội yếu hơn cho party mode!"); }

function chooseForOpponent() { const source = filteredTeams; if (!source.length) return; const other = pickRandom(source); setResult({ type: "single", a: other, note: "Đội dành cho đối phương" }); saveHistory({ type: "single", a: other, mode, effect, createdAt: new Date().toISOString(), special: "opponent" }); setConfetti(makeConfetti(44)); }

function extraDraw() { runRandom({ fromSpecial: true }); setTimeout(() => runRandom({ fromSpecial: true }), 250); }

function banLeagueRandom() { setBannedLeague(pickRandom(LEAGUES)); setPartyMessage("Một giải đấu đã bị cấm ngẫu nhiên."); }

function shareResult() { if (!result) return; const text = result.type === "pair" ? PES/eFootball Random: ${result.a.name} vs ${result.b.name} : PES/eFootball Random: ${result.a.name}; if (navigator.share) { navigator.share({ title: "PES Random", text }).catch(() => {}); } else if (navigator.clipboard) { navigator.clipboard.writeText(text).catch(() => {}); ann
stdout
Standard output is empty