Submission #302465

# Submission time Handle Problem Language Result Execution time Memory
302465 2020-09-18T17:34:41 Z BlancaHM Regions (IOI09_regions) C++14
Compilation error
0 ms 0 KB
#include "regions.h"
#include <iostream>
#include <fstream>
#include <cfloat>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>
#include <climits>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<string> vs;
#define fir first
#define sec second
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()

vi country;
vvi G;
int N, R;
vector<map<int, int>> below;
vvi countryCit;

void dfs(int S) {
	for (auto v: G[S]) {
		dfs(v);
		for (auto const &a: below[v]) {
			below[S][a.first] += below[v][a.first];
		}
		below[S][country[v]-1]++;
	}
}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(NULL);
	int Q, cn, sup, e1, e2, ans;
	cin >> N >> R >> Q;
	G.assign(N, vi());
	countryCit.assign(N, vi());
	country = vi(N);
	below.assign(N, map<int, int>());
	cin >> cn;
	country[0] = cn;
	countryCit[cn-1].pb(0);
	for (int i = 1; i < N; i++) {
		cin >> sup >> cn;
		G[sup-1].push_back(i);
		country[i] = cn;
		countryCit[cn-1].pb(i);
	}
	dfs(0);
	while(Q--) {
		cin >> e1 >> e2;
		ans = 0;
		for (auto cit: countryCit[e1-1]) {
			ans += below[cit][e2-1];
		}
		cout << ans << "\n";
		cout.flush();
	}
	return 0;
}

Compilation message

regions.cpp:1:10: fatal error: regions.h: No such file or directory
    1 | #include "regions.h"
      |          ^~~~~~~~~~~
compilation terminated.