Submission #39117

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
391172018-01-09 11:08:0614kgIdeal city (IOI12_city)C++11
100 / 100
909 ms64948 KiB
#include <map>
#include <algorithm>
#include <vector>
#include <stdio.h>
#define N 100000
#define MOD 1000000000
#define INF 2147483646
#define min2(x,y) (x<y?x:y)
#define max2(x,y) (x>y?x:y)
using namespace std;
int n, tree1_len, tree2_len, tree1_cnt[N], tree2_cnt[N];
long long out;
pair<int, long long> t_save[N];
vector<int> tree1[N], tree2[N];
map<int, int > tree1_NUM[N], tree2_NUM[N];
map<int, bool> M[N], tree1_link[N], tree2_link[N];
pair<int, long long> count_tree1(int lev, int up) {
long long cnt = 0, t = 0;
pair<int, long long> temp;
for (auto i : tree1[lev])
if (i != up) {
t_save[i] = temp = count_tree1(i, lev);
t += temp.second, cnt += temp.first;
}
for (auto i : tree1[lev])
if (i != up)
out += (long long)t_save[i].first*(t - t_save[i].second), out %= MOD;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...