http://orac.amt.edu.au/fario/11/problems_en.pdf fourth problem
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
http://orac.amt.edu.au/fario/11/problems_en.pdf fourth problem
Название |
---|
It looks like a usual dp on a tree. I think you should write a comparator, like 'What vertex we should go into?'. Then run DFS, and at each step sort all children of the current vertex by this comparator and visit them in this exact order. Once you visit a subtree, it becomes a vertex with its own parameters.
I may be wrong, but it's the first solution I would think of.
i will write comparator but which priority? i have no idea
Write the mathematical expression, what number of citizen will be dead if we go to the first city and then to the second. Then write the same expression if you visit the cities in the opposite order. Sign of the difference of these values will show which city of these two should be visited first.
i try this but i can't, i will try this once again
my code is here and i dont know is it true solution
define fi first
define se second
define SIZE(A) ((int)A.size())
define pb push_back
using namespace std;
const int MAXN = 100010;
typedef pair<int,int> ii;
vector way[MAXN];
int n;
long long vic[MAXN];
struct node{
}ar[MAXN];
typedef set::iterator sit;
set G[MAXN];
bool used[MAXN];
node rec(int k,int t){
}
long long f(int k){
}
int main(){
}
my bug is "set", it will be "multiset". thanks dalex
Use vectors + sorting next time, it should be a bit faster than sets with their red-black trees.
AppleZ the previous comment for my wrong idea. Thanks
Sorry...