There are some problems, whose algorithms do not fall into well studied solutions of standard categories.
Ad-Hoc falls in one of them. Each and every Ad-Hoc problem is unique, different from other problems, and no general solution or technique exist to solve them.
Well, it is good to come across such problems, as your brain will be shaped in a way to crack a problem in many different ways. The solutions might require a complete new user-made data structure, or some sort of special combinations, or unusual set of loops or conditions.
While solving Ad-Hoc problems, you are required to read the problem very carefully, and produce a solution which satisfies all the constraints and conditions mentioned in the Problem Statement.
Though, each and every problem requires a new solution, it is mandatory to keep in mind that Time and Space trade-offs are still maintained. For that, you need to optimize your code, and come up with an efficient solution.