Fix memory leak

The `new` allocation in the `main()` function isn't always deleted within `solve`.

Easily fixed by replacing the dangerous naked `new` and `delete` operations with `unique_ptr`.