# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
302797 |
2020-09-19T08:31:50 Z |
BlancaHM |
Regions (IOI09_regions) |
C++14 |
|
8000 ms |
20984 KB |
#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, e1, e2, ans;
int dfs(int S) {
int cur = 0;
for (auto v: G[S]) {
cur += dfs(v);
if (country[v] == e2) cur++;
}
if (country[S] == e1) ans += cur;
return cur;
}
int main() {
//ios::sync_with_stdio(false);
//cin.tie(NULL);
int Q, cn, sup;
cin >> N >> R >> Q;
G.assign(N, vi());
country = vi(N);
cin >> cn;
country[0] = cn;
for (int i = 1; i < N; i++) {
cin >> sup >> cn;
G[sup-1].push_back(i);
country[i] = cn;
}
while(Q--) {
cin >> e1 >> e2;
ans = 0;
dfs(0);
cout << ans << "\n";
cout.flush();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
13 ms |
384 KB |
Output is correct |
6 |
Correct |
36 ms |
384 KB |
Output is correct |
7 |
Correct |
100 ms |
512 KB |
Output is correct |
8 |
Correct |
132 ms |
384 KB |
Output is correct |
9 |
Correct |
271 ms |
768 KB |
Output is correct |
10 |
Correct |
1811 ms |
896 KB |
Output is correct |
11 |
Correct |
3827 ms |
1152 KB |
Output is correct |
12 |
Correct |
3860 ms |
1656 KB |
Output is correct |
13 |
Execution timed out |
8018 ms |
1400 KB |
Time limit exceeded |
14 |
Execution timed out |
8045 ms |
1912 KB |
Time limit exceeded |
15 |
Correct |
7505 ms |
4612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
8061 ms |
5244 KB |
Time limit exceeded |
2 |
Execution timed out |
8100 ms |
4344 KB |
Time limit exceeded |
3 |
Execution timed out |
8077 ms |
7288 KB |
Time limit exceeded |
4 |
Execution timed out |
8035 ms |
1912 KB |
Time limit exceeded |
5 |
Execution timed out |
8021 ms |
3576 KB |
Time limit exceeded |
6 |
Execution timed out |
8007 ms |
3320 KB |
Time limit exceeded |
7 |
Execution timed out |
8073 ms |
4216 KB |
Time limit exceeded |
8 |
Execution timed out |
8021 ms |
9336 KB |
Time limit exceeded |
9 |
Execution timed out |
8055 ms |
9592 KB |
Time limit exceeded |
10 |
Execution timed out |
8051 ms |
14584 KB |
Time limit exceeded |
11 |
Execution timed out |
8057 ms |
9572 KB |
Time limit exceeded |
12 |
Execution timed out |
8004 ms |
11512 KB |
Time limit exceeded |
13 |
Execution timed out |
8009 ms |
11768 KB |
Time limit exceeded |
14 |
Execution timed out |
8038 ms |
11384 KB |
Time limit exceeded |
15 |
Execution timed out |
8077 ms |
15352 KB |
Time limit exceeded |
16 |
Execution timed out |
8073 ms |
20984 KB |
Time limit exceeded |
17 |
Execution timed out |
8053 ms |
19812 KB |
Time limit exceeded |