Submission #872519

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
8725192023-11-13 09:24:39overwatch9Regions (IOI09_regions)C++17
100 / 100
3982 ms66764 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 2e5 + 10;
const int maxr = 25000 + 10;
vector <int> adj[maxn];
int region[maxn];
vector <int> region_members[maxr];
int visit[maxn], finish[maxn];
int n, r, q, t = 0;
void dfs(int s) {
visit[s] = t++;
for (auto i : adj[s])
dfs(i);
finish[s] = t++;
}
vector <vector <int>> r1r2, cnt;
int big_region_cnt = 0;
int big_id[maxn];
void dfs2(int s, int p) {
int id1 = big_id[region[s]];
int id2 = big_id[region[p]];
cnt[s] = cnt[p];
if (id2 != -1 && s != p)
cnt[s][id2]++;
if (id1 != -1) {
for (int i = 0; i < big_region_cnt; i++)
r1r2[i][id1] += cnt[s][i];
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...