Skip to content
Solved SPOJ problems
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore fix niceday-2.cpp Jan 30, 2015
LICENSE Initial import of code Oct 8, 2014
README.md update readme Oct 8, 2014
aba12d.cpp
abcd.cpp
abcdef.cpp Initial import of code Oct 8, 2014
abcpath.cpp
absp1.cpp Initial import of code Oct 8, 2014
absys.cpp
acmaker.cpp
acode.cpp
acpc10a.cpp Initial import of code Oct 8, 2014
acpc10d.cpp Initial import of code Oct 8, 2014
acpc10e.cpp
acpc11b.cpp Initial import of code Oct 8, 2014
acquire.cpp add ACQUIRE Oct 10, 2014
acs.cpp Convert all DOS line endings to Unix Jan 30, 2015
act.cpp Initial import of code Oct 8, 2014
addrev.cpp Initial import of code Oct 8, 2014
adv04j.cpp Initial import of code Oct 8, 2014
ae00.cpp Initial import of code Oct 8, 2014
ae2a.cpp
ae2b.cpp
ae5b2.cpp
aggrcow.cpp Convert all DOS line endings to Unix Jan 30, 2015
aibohp.cpp Convert all DOS line endings to Unix Jan 30, 2015
alibb.cpp Initial import of code Oct 8, 2014
alicesie.cpp
alien.cpp Initial import of code Oct 8, 2014
aliens.cpp Convert all DOS line endings to Unix Jan 30, 2015
amr10g.cpp Initial import of code Oct 8, 2014
amr11e.cpp Initial import of code Oct 8, 2014
amr12d.cpp
amzrck.cpp Initial import of code Oct 8, 2014
amzseq.cpp Initial import of code Oct 8, 2014
anarc05b.cpp Initial import of code Oct 8, 2014
anarc05h.cpp Initial import of code Oct 8, 2014
anarc08b.cpp Initial import of code Oct 8, 2014
anarc08g.cpp
anarc08h.cpp Initial import of code Oct 8, 2014
anarc09a-1.cpp Initial import of code Oct 8, 2014
anarc09a-2.cpp Initial import of code Oct 8, 2014
anarc09b.cpp
ap2.cpp
aps.cpp Initial import of code Oct 8, 2014
arctan.pas Initial import of code Oct 8, 2014
arith.cpp
arith2.cpp Initial import of code Oct 8, 2014
army.cpp Convert all DOS line endings to Unix Jan 30, 2015
arrange.cpp
arraysub.cpp Initial import of code Oct 8, 2014
assign.cpp Initial import of code Oct 8, 2014
assist.cpp Initial import of code Oct 8, 2014
babtwr.cpp Convert all DOS line endings to Unix Jan 30, 2015
backpack.cpp Initial import of code Oct 8, 2014
baised.cpp Convert all DOS line endings to Unix Jan 30, 2015
balife.cpp Initial import of code Oct 8, 2014
bandw.cpp
base.cpp
bc.cpp
beads.cpp Initial import of code Oct 8, 2014
beenums.cpp Initial import of code Oct 8, 2014
benefact.cpp Initial import of code Oct 8, 2014
bia.cpp Initial import of code Oct 8, 2014
billiard.cpp Initial import of code Oct 8, 2014
bingo.cpp
binstirl.cpp Convert all DOS line endings to Unix Jan 30, 2015
bishops.cpp Convert all DOS line endings to Unix Jan 30, 2015
bitmap.cpp Convert all DOS line endings to Unix Jan 30, 2015
blinnet.cpp Convert all DOS line endings to Unix Jan 30, 2015
bmj.cpp
boi7seq.cpp
bomarble.cpp Initial import of code Oct 8, 2014
books1.cpp
brckts.cpp Convert all DOS line endings to Unix Jan 30, 2015
bri.cpp Initial import of code Oct 8, 2014
brii.cpp Initial import of code Oct 8, 2014
broken.cpp Initial import of code Oct 8, 2014
bsheep.cpp
buglife.cpp Initial import of code Oct 8, 2014
busyman.cpp Initial import of code Oct 8, 2014
bwheeler.cpp Convert all DOS line endings to Unix Jan 30, 2015
bwidow.cpp
byecakes.cpp Initial import of code Oct 8, 2014
bytese1.cpp Initial import of code Oct 8, 2014
bytese2.cpp Initial import of code Oct 8, 2014
bytesm2.cpp Initial import of code Oct 8, 2014
cadydist.cpp Initial import of code Oct 8, 2014
candy.cpp Convert all DOS line endings to Unix Jan 30, 2015
candy2.cpp Initial import of code Oct 8, 2014
candy3.cpp
canton.cpp Initial import of code Oct 8, 2014
capcity.cpp
catm.cpp
cattleb.cpp Initial import of code Oct 8, 2014
cerc07b.cpp Convert all DOS line endings to Unix Jan 30, 2015
cerc07c.cpp Initial import of code Oct 8, 2014
cerc07k.cpp Convert all DOS line endings to Unix Jan 30, 2015
cerc07n.cpp Convert all DOS line endings to Unix Jan 30, 2015
cerc07p.cpp
cerc07r.cpp Convert all DOS line endings to Unix Jan 30, 2015
chain.cpp
chicago.cpp
chocola.cpp Convert all DOS line endings to Unix Jan 30, 2015
cistfill.cpp Initial import of code Oct 8, 2014
civil.cpp Initial import of code Oct 8, 2014
clk.cpp Convert all DOS line endings to Unix Jan 30, 2015
clone.cpp
cmexpr.cpp
cmpls.cpp Convert all DOS line endings to Unix Jan 30, 2015
cneasy.cpp Convert all DOS line endings to Unix Jan 30, 2015
code.cpp Initial import of code Oct 8, 2014
codesptb.cpp
coef.cpp Initial import of code Oct 8, 2014
coins.cpp Initial import of code Oct 8, 2014
comdiv.cpp
count.c
cowcar.cpp Convert all DOS line endings to Unix Jan 30, 2015
cowpic.cpp add COWPIC Apr 14, 2017
cpc.cpp
cpcrc1c.cpp Initial import of code Oct 8, 2014
cprmt.cpp Convert all DOS line endings to Unix Jan 30, 2015
crds.cpp Initial import of code Oct 8, 2014
crscntry.cpp Initial import of code Oct 8, 2014
cstreet.cpp Convert all DOS line endings to Unix Jan 30, 2015
ctgame.cpp
ctrick.cpp Convert all DOS line endings to Unix Jan 30, 2015
cubefr.cpp
cubes.cpp
cwc2015.cpp add CWC201 Nov 5, 2015
cylinder.cpp Initial import of code Oct 8, 2014
danger.cpp Convert all DOS line endings to Unix Jan 30, 2015
dcepc504.cpp
depend.cpp Convert all DOS line endings to Unix Jan 30, 2015
dfloor.cpp Initial import of code Oct 8, 2014
diehard.cpp
distance.cpp Convert all DOS line endings to Unix Jan 30, 2015
disubstr.cpp Initial import of code Oct 8, 2014
div15.cpp Initial import of code Oct 8, 2014
dna.cpp Convert all DOS line endings to Unix Jan 30, 2015
dnpalin.cpp
dotaa.cpp Initial import of code Oct 8, 2014
double.cpp
dpair.cpp Initial import of code Oct 8, 2014
dquery.cpp
drink.cpp Convert all DOS line endings to Unix Jan 30, 2015
dsubseq.cpp Initial import of code Oct 8, 2014
dtt.cpp Convert all DOS line endings to Unix Jan 30, 2015
dyzio.cpp Convert all DOS line endings to Unix Jan 30, 2015
eboxes.cpp Initial import of code Oct 8, 2014
ec_conb.cpp Initial import of code Oct 8, 2014
edist.cpp Initial import of code Oct 8, 2014
edit.cpp
egypizza.cpp Initial import of code Oct 8, 2014
eights.cpp Convert all DOS line endings to Unix Jan 30, 2015
empty.cpp Convert all DOS line endings to Unix Jan 30, 2015
en.cpp
enigmath.cpp
eqbox.cpp Convert all DOS line endings to Unix Jan 30, 2015
etf.cpp Initial import of code Oct 8, 2014
facefrnd.cpp Initial import of code Oct 8, 2014
fact0.cpp Initial import of code Oct 8, 2014
faketsp.cpp
fancy.cpp Initial import of code Oct 8, 2014
farida.cpp Initial import of code Oct 8, 2014
fashion.cpp Convert all DOS line endings to Unix Jan 30, 2015
fastflow.cpp
favdice.cpp Initial import of code Oct 8, 2014
fctrl.cpp Initial import of code Oct 8, 2014
fctrl2.cpp
fctrl4.cpp Convert all DOS line endings to Unix Jan 30, 2015
fence1.cpp
fence3.cpp Initial import of code Oct 8, 2014
fibosum.cpp Initial import of code Oct 8, 2014
fibosum2.cpp Initial import of code Oct 8, 2014
fisher.cpp Initial import of code Oct 8, 2014
flbrklin.cpp Initial import of code Oct 8, 2014
fool.cpp Initial import of code Oct 8, 2014
fpolice.cpp
frequent.cpp Convert all DOS line endings to Unix Jan 30, 2015
fseats.cpp Convert all DOS line endings to Unix Jan 30, 2015
galou.cpp
games.cpp Initial import of code Oct 8, 2014
gardenar.cpp Initial import of code Oct 8, 2014
gcd2.cpp Convert all DOS line endings to Unix Jan 30, 2015
gcd3.cpp add GCD3 Jul 2, 2016
gcpc11f.cpp Initial import of code Oct 8, 2014
geoprob.py Initial import of code Oct 8, 2014
ghosts.cpp add GHOSTS Jul 9, 2017
girlsnbs.cpp
giveaway-1.cpp
giveaway-2.cpp Initial import of code Oct 8, 2014
glasnici.cpp Convert all DOS line endings to Unix Jan 30, 2015
gljive.cpp
gny07c.cpp Convert all DOS line endings to Unix Jan 30, 2015
gny07d.cpp
gny07e.cpp
gny07f.cpp Convert all DOS line endings to Unix Jan 30, 2015
gny07g.cpp
gny07h.cpp
gnyr09f.cpp
gossipers.cpp Convert all DOS line endings to Unix Jan 30, 2015
grc.cpp
gshop.cpp Initial import of code Oct 8, 2014
gss1.cpp Convert all DOS line endings to Unix Jan 30, 2015
gss2.cpp Initial import of code Oct 8, 2014
gss3.cpp Initial import of code Oct 8, 2014
gss5.cpp
guanggun.cpp Initial import of code Oct 8, 2014
hamster1.cpp
hangover.cpp Convert all DOS line endings to Unix Jan 30, 2015
hashit.cpp Convert all DOS line endings to Unix Jan 30, 2015
hc.cpp
headshot.cpp Initial import of code Oct 8, 2014
helpbtw.cpp
hepnum.cpp Initial import of code Oct 8, 2014
highways.cpp Initial import of code Oct 8, 2014
histogra.cpp
horrible.cpp Convert all DOS line endings to Unix Jan 30, 2015
hotels.c Initial import of code Oct 8, 2014
hpynos.cpp Initial import of code Oct 8, 2014
hubullu.cpp Convert all DOS line endings to Unix Jan 30, 2015
icampseq.cpp
icoder.cpp Convert all DOS line endings to Unix Jan 30, 2015
ieeebgam.cpp Initial import of code Oct 8, 2014
iitkwpcb.cpp Initial import of code Oct 8, 2014
iitkwpco-2.cpp Initial import of code Oct 8, 2014
im-1.cpp Initial import of code Oct 8, 2014
im-2.cpp
image.cpp Initial import of code Oct 8, 2014
incseq.cpp Initial import of code Oct 8, 2014
invcnt.cpp
invent.cpp
jasiek.cpp Convert all DOS line endings to Unix Jan 30, 2015
javac.cpp Convert all DOS line endings to Unix Jan 30, 2015
jnext-1.cpp
jnext-2.cpp Initial import of code Oct 8, 2014
jpix.cpp Initial import of code Oct 8, 2014
julka.cpp Convert all DOS line endings to Unix Jan 30, 2015
kgss.cpp Initial import of code Oct 8, 2014
kpmatrix.cpp Initial import of code Oct 8, 2014
kpsort.cpp Initial import of code Oct 8, 2014
kpursuit.cpp
krow.cpp Convert all DOS line endings to Unix Jan 30, 2015
kruskal.cpp Convert all DOS line endings to Unix Jan 30, 2015
labyr1.cpp Convert all DOS line endings to Unix Jan 30, 2015
laser_beam.cpp add LASER_BEAM Jul 25, 2016
lastdig.cpp Initial import of code Oct 8, 2014
lastdig2.cpp
lengfact.cpp Initial import of code Oct 8, 2014
leonardo.cpp Convert all DOS line endings to Unix Jan 30, 2015
lexbrac.cpp Convert all DOS line endings to Unix Jan 30, 2015
lines.cpp
lis2.cpp Convert all DOS line endings to Unix Jan 30, 2015
lite.cpp
lqdcandy.cpp Initial import of code Oct 8, 2014
lsort.cpp Convert all DOS line endings to Unix Jan 30, 2015
m00pair.cpp Initial import of code Oct 8, 2014
m3tile.cpp
major.cpp Initial import of code Oct 8, 2014
mangoes.cpp
marbles.py Initial import of code Oct 8, 2014
matriosh.cpp Convert all DOS line endings to Unix Jan 30, 2015
matsum.c Initial import of code Oct 8, 2014
maxln.cpp
may99_2.cpp
maya.cpp
mbeewalk.cpp
mcirgame.py Initial import of code Oct 8, 2014
mcoins.cpp Initial import of code Oct 8, 2014
mflar10.cpp
micemaze.cpp Initial import of code Oct 8, 2014
mincount.cpp Initial import of code Oct 8, 2014
minmove.cpp Initial import of code Oct 8, 2014
minus.cpp Convert all DOS line endings to Unix Jan 30, 2015
miserman.cpp
mixtures.cpp Convert all DOS line endings to Unix Jan 30, 2015
mklabels.cpp Initial import of code Oct 8, 2014
mkmoney.cpp
mlaserp.cpp Initial import of code Oct 8, 2014
mmaxper.cpp Initial import of code Oct 8, 2014
mmmgame.cpp
mon2012.cpp add MON2012 Apr 30, 2016
morse.cpp
mrecaman.cpp Initial import of code Oct 8, 2014
mul.cpp Convert all DOS line endings to Unix Jan 30, 2015
multq3.cpp Initial import of code Oct 8, 2014
musket.cpp Convert all DOS line endings to Unix Jan 30, 2015
myq1.cpp Initial import of code Oct 8, 2014
neg2.cpp Convert all DOS line endings to Unix Jan 30, 2015
ng0frctn-1.cpp Initial import of code Oct 8, 2014
ng0frctn-2.cpp Initial import of code Oct 8, 2014
ngm.cpp Initial import of code Oct 8, 2014
nhay-1.cpp Convert all DOS line endings to Unix Jan 30, 2015
nhay-2.cpp add second solution for NHAY Oct 9, 2014
niceday-1.cpp Initial import of code Oct 8, 2014
niceday-2.cpp
nitt2.cpp Initial import of code Oct 8, 2014
notatri.cpp Convert all DOS line endings to Unix Jan 30, 2015
nsteps.cpp Convert all DOS line endings to Unix Jan 30, 2015
nsystem.cpp
ny10a.cpp
ny10e.cpp Initial import of code Oct 8, 2014
offside.cpp Initial import of code Oct 8, 2014
ololo.cpp
onezero.cpp Initial import of code Oct 8, 2014
onp.cpp Convert all DOS line endings to Unix Jan 30, 2015
orders-1.cpp Initial import of code Oct 8, 2014
palace.cpp
paldr.cpp Initial import of code Oct 8, 2014
palim.cpp
palin.cpp Convert all DOS line endings to Unix Jan 30, 2015
paradox.cpp add PARADOX Apr 29, 2016
parket1.cpp Initial import of code Oct 8, 2014
party.cpp Convert all DOS line endings to Unix Jan 30, 2015
pb.cpp Initial import of code Oct 8, 2014
pebble.cpp
pebbmov.cpp Initial import of code Oct 8, 2014
permut1.cpp Convert all DOS line endings to Unix Jan 30, 2015
permut2.cpp Convert all DOS line endings to Unix Jan 30, 2015
pfdep.cpp Convert all DOS line endings to Unix Jan 30, 2015
phonelst.cpp Initial import of code Oct 8, 2014
pie.cpp
pigbank.cpp Convert all DOS line endings to Unix Jan 30, 2015
pir.cpp Convert all DOS line endings to Unix Jan 30, 2015
pld.cpp
plhop.cpp Convert all DOS line endings to Unix Jan 30, 2015
plonk.cpp
poker.cpp Initial import of code Oct 8, 2014
poleval.cpp Initial import of code Oct 8, 2014
polygame.cpp Convert all DOS line endings to Unix Jan 30, 2015
pon.py Initial import of code Oct 8, 2014
posters.cpp
pothole.cpp Initial import of code Oct 8, 2014
pour1.cpp
ppath.cpp Convert all DOS line endings to Unix Jan 30, 2015
pqueue.cpp Convert all DOS line endings to Unix Jan 30, 2015
prime1.cpp Convert all DOS line endings to Unix Jan 30, 2015
prismsa.cpp
pro.cpp
pt07x.cpp Convert all DOS line endings to Unix Jan 30, 2015
pt07y.cpp Convert all DOS line endings to Unix Jan 30, 2015
pt07z.cpp
ptime.cpp
pucmm025.cpp Initial import of code Oct 8, 2014
pucmm210.cpp Initial import of code Oct 8, 2014
pucmm334.cpp add PUCMM334 Apr 29, 2016
qcj4.cpp Initial import of code Oct 8, 2014
qtree.cpp
qtree2.cpp Initial import of code Oct 8, 2014
quadarea.cpp Convert all DOS line endings to Unix Jan 30, 2015
queen.cpp
quest4.cpp Initial import of code Oct 8, 2014
rabbit1.cpp Convert all DOS line endings to Unix Jan 30, 2015
rain3.cpp Convert all DOS line endings to Unix Jan 30, 2015
ranjan02.py
rent.cpp Initial import of code Oct 8, 2014
resist.cpp Initial import of code Oct 8, 2014
righttri.cpp Initial import of code Oct 8, 2014
roadnet.cpp
roads.cpp Convert all DOS line endings to Unix Jan 30, 2015
rock.cpp Convert all DOS line endings to Unix Jan 30, 2015
rootciph.cpp
rplc.cpp Initial import of code Oct 8, 2014
rple.cpp Initial import of code Oct 8, 2014
rplh.cpp
rrsched.cpp Convert all DOS line endings to Unix Jan 30, 2015
sa04d.cpp Initial import of code Oct 8, 2014
samer08f.cpp Initial import of code Oct 8, 2014
sbank.cpp Convert all DOS line endings to Unix Jan 30, 2015
sbets.cpp Initial import of code Oct 8, 2014
scale.cpp
scavhunt.cpp Initial import of code Oct 8, 2014
scpc11b.cpp Initial import of code Oct 8, 2014
scubadiv.cpp Convert all DOS line endings to Unix Jan 30, 2015
seq.cpp
shahbg.cpp
shop.cpp Convert all DOS line endings to Unix Jan 30, 2015
shpath.cpp Convert all DOS line endings to Unix Jan 30, 2015
silver.cpp
speed.cpp
sqrbr.cpp
stablemp.cpp
stamps.cpp Initial import of code Oct 8, 2014
stone.cpp Convert all DOS line endings to Unix Jan 30, 2015
stpar.cpp Convert all DOS line endings to Unix Jan 30, 2015
streetr.cpp
ststring.cpp Initial import of code Oct 8, 2014
subseq.cpp Convert all DOS line endings to Unix Jan 30, 2015
subst1.c Initial import of code Oct 8, 2014
subsums.cpp
sum1seq.cpp
sumfour.cpp Initial import of code Oct 8, 2014
sumitr.cpp Convert all DOS line endings to Unix Jan 30, 2015
sumsums.cpp
table5x5.cpp
tcount2.cpp Convert all DOS line endings to Unix Jan 30, 2015
tcount3.cpp Convert all DOS line endings to Unix Jan 30, 2015
tdkprime.cpp Initial import of code Oct 8, 2014
team2.cpp Initial import of code Oct 8, 2014
temptisl.cpp
test.asm
test.cpp
tetra.cpp
tfoss.cpp Initial import of code Oct 8, 2014
threecol.cpp Initial import of code Oct 8, 2014
tiling.cpp Convert all DOS line endings to Unix Jan 30, 2015
toandfro.cpp Convert all DOS line endings to Unix Jan 30, 2015
toe1.cpp
toe2.cpp
tohu.cpp Initial import of code Oct 8, 2014
tour.cpp Convert all DOS line endings to Unix Jan 30, 2015
treegame.cpp Initial import of code Oct 8, 2014
trgrid.cpp Initial import of code Oct 8, 2014
tricentr.cpp Convert all DOS line endings to Unix Jan 30, 2015
tricount.cpp
trika.cpp
tripart.cpp Convert all DOS line endings to Unix Jan 30, 2015
trt.cpp Convert all DOS line endings to Unix Jan 30, 2015
tshow1.cpp
twends.cpp Initial import of code Oct 8, 2014
twice.c
twinsnow.cpp Initial import of code Oct 8, 2014
twosqrs.cpp Convert all DOS line endings to Unix Jan 30, 2015
uj.py Initial import of code Oct 8, 2014
water-2.cpp add simple solution for WATER Dec 19, 2018
water.cpp
wild.cpp
willitst.cpp Initial import of code Oct 8, 2014
wordcnt.cpp
words1.cpp Convert all DOS line endings to Unix Jan 30, 2015
wpc4f.cpp Initial import of code Oct 8, 2014
wpuzzles.cpp
wscipher.cpp Initial import of code Oct 8, 2014
yapp.cpp Initial import of code Oct 8, 2014
yodaness.cpp Initial import of code Oct 8, 2014
zsum.cpp Initial import of code Oct 8, 2014

README.md

SPOJ

This repository contains solutions to almost all problems I have solved on SPOJ. They're intended as a last resort in case you've tried very hard to solve a problem but you just haven't been able to figure it out. When I was trying to solve GSS2, I mostly found vague hints on online forums, which weren't helpful. I wasn't able to solve the problem until after I looked at some code. So obviously the code helps, and there can be good reasons to just look at code rather than being stuck indefinitely.

Some of the files in this repository differ from my submitted solutions in relatively trivial ways, such as the removal of commented-out code or #ifdef'd code for an archaic compiler I used to use (Microsoft Visual C++ 6.0). However, I suspect some of them simply don't work because either they contained errors that I corrected while away from home (so the changes were not saved locally) or I made modifications locally that turned out to give incorrect solutions and forgot to revert to the older versions. If you discover an incorrect solution, please leave a comment so I can fix it!

The copyright notice (LICENSE) applies to all code except for a few algorithms copied from the Stanford ACM team notebook, which are indicated as such. There is technically no license for that code that I'm aware of, but it's unlikely you'll get into any trouble for using it or redistributing it freely. A recent version of the Stanford ACM team notebook can be found here.

There is a comment at the beginning of each file that gives the date on which the solution was submitted. Caution: Many of the older solutions have bad coding style and poor mastery of C++.

For a few problems I have multiple solutions, usually because after my first successful submission I discovered there was a much better way to solve the problem. Those are indicated as e.g. niceday-1.cpp and niceday-2.cpp. There is no possible ambiguity as SPOJ problem names aren't allowed to contain dashes (as far as I know, anyway).

You can’t perform that action at this time.