Use your brain, think logically and just do it!
I'll give you a tip:
These are the things I included:
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <climits>