SPOJ MEOWIST

The Problem
This problem should be a practise problem
It took me 20mins to solve it =) , I am too rusted lately but hopefully I will post a new problem everyday from now on

#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>

using namespace std;

class person{
public:
int age;
[...]

SPOJ Twinsnow solution

Started to code with a challenge, this problem turned out to be really simple
My friend tried out hashing and it timed out
My approach was to sort the 6 lengths, then sort all the snowflakes, and if the sorted parts match, it compares actual snowflakes
If snowflakes are equal, then when you sort their lengths the sorted [...]

METU CENG242 Hw3 Solution

The problem statement and input outputs are here
The task was to implement a QuadTree
The good thing about functional languages is that when you have a specification, writing the code is trivial and extremely fun
Also unlike programming in languages like C, performance is not a worry, rather than performance, style and practicality of the program matters
I [...]

METU CENG242 Hw3 Input Output

Problem Statement
Some of the input outputs in raw form
Inputs:

a=(new 10)
b=(negate (new 10))
c=insert ((2,3),(8,9)) (new 10)
d=delete ((5,5),(5,5)) (delete ((8,1),(9,8)) (negate (new 10)))
[...]

Topcoder SRM437 Div1 500 Point

Problem Statement: http://www.topcoder.com/stat?c=problem_statement&pm=10231&rd=13699&rm=300710&cr=22655725
I decided to use dynamic problem because it would %100 work and result in time
Main problem was that at contest time i didn’t check digits to be exactly K,

Solution for SPOJ PLD Palindromes

This problem is one of the best problems i solved because my solution is not %100 correct but its probability to solve the problem correctly is very near to 100 percent
The problem asks to count all palindromes of length k on a string of length n Since k,n

K length Palindromes in a String Solution Idea

The problem: https://www.spoj.pl/problems/PLD/
With rabin karp hash all string of K/2 length,
Then if there is a hash value collision search for the start of the current string being searched, if it is the end of another string increment
Hash structure is a binary tree

SHOCALC

Try writing a c code without “;” and “!”
http://www.spoj.pl/problems/SHOCALC/
It is an extremely fun problem
Here is my solution:

main(int a,int b,int c){while(scanf("%d%d%d",&a,&b,&c)>0){if(a=a<3?a<2?b+c:b-c:a>4?b%c:a>3?b/c:b*c,printf("%d\n",a)){}}}

Only problem is i couldn’t return 0, or exit(0) without a “;”, it turns out that the problem setter didn’t check “;” condition
so if you add an exit(“0”); it will pass
EDIT:
Here is the last [...]

Halloween treats

https://www.spoj.pl/problems/HALLOW/
Solution:
Problem H: Halloween treats
This problem probably would have been easier given following hint: There always exists a solution with a selection of consecutive neighbours. The reason why this is true follows from the fact that c ≤ n, using the pigeonhole principle.
Let us define partial sums Si as the sum of the first i values [...]