Skip to content

Instantly share code, notes, and snippets.

Constrangeri:
* timp de executie: 1 sec
Explicatie:
Rezolvam problema prin metoda programarii dinamice. Odata impartit fisierul in cuvinte,
pentru fiecare grup de cuvinte consecutive calculam penalitatea p asociata unei linii
care le contine.
* l[i] = lungimea cuvantului i
* p[i][j] = t[i][j] * t[i][j], daca t[i][j] >= 0
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Parser
{
enum TokenType
{
#ifndef _NDEBUG
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif
#include <algorithm>
#include <chrono>
#include <fstream>
#include <functional>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using System.Drawing;
namespace ImageChecker
{
rem ghc -O2 -auto-all -prof --make slowsilver && slowsilver +RTS -p -hc && hp2ps slowsilver
ghc -O2 -auto-all -prof --make slowsilver && slowsilver +RTS -p
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace ThreadRingTask
{
class Agent
{
public Agent Next;
import Control.Monad
import Data.Char
import Data.List
import System.Environment
import Control.Monad.Instances
main = getArgs >>= mapM (liftM lines . readFile) >>= return . liftM2 zip head (head . tail)
module Main (main) where
import Control.Parallel.Strategies
import Control.Monad
import Data.Char
solve s (x : xs) = (solve x xs >>= \r -> [s + r, s - r]) ++ solve (10 * s + x) xs
solve s _ = [s]
ugly x = x `mod` 2 == 0 || x `mod` 3 == 0 || x `mod` 5 == 0 || x `mod` 7 == 0
module Main where
import Control.Monad
import Data.Char
import Data.List
import Data.Ord
process = reverse . (sortBy $ comparing snd) . (map $ \x -> (head x, length x)) . group . sort . words . map toLower . filter (flip notElem "().,\"")
main = getContents >>= print . process
module Main where
import Data.Ix
data Cell = Cell
{
position :: (Integer, Integer, Integer),
value :: String
}