Submission #722457

# Submission time Handle Problem Language Result Execution time Memory
722457 2023-04-12T02:58:53 Z ono_de206 Regions (IOI09_regions) C++14
0 / 100
109 ms 32520 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T, typename U>
ostream & operator << (ostream &out, const pair<T, U> &c) {
	out << c.first << ' ' << c.second;
    return out;
}

template<typename T>
ostream & operator << (ostream &out, vector<T> &v) {
	const int sz = v.size();
	for (int i = 0; i < sz; i++) {
		if (i) out << ' ';
		out << v[i];
	}
    return out;
}

template<typename T>
istream & operator >> (istream &in, vector<T> &v) {
	for (T &x : v) in >> x;
    return in;
}


template<typename T>
void mxx(T &a, T b){if(b > a) a = b;}
template<typename T>
void mnn(T &a, T b){if(b < a) a = b;}

const int mxn = 2e5 + 10, B = 400;
int cnt[500][mxn], in[mxn], out[mxn], tt, kk[mxn], s[mxn], h[mxn];
vector<int> g[mxn], p[mxn], d[mxn];

void dfs(int to) {
	in[to] = ++tt;
	d[h[to]].pb(in[to]);
	for(int x : g[to]) {
		dfs(x);
	}
	out[to] = tt;
}

void solve(int to, int cn, int id) {
	cnt[kk[id]][h[to]] += cn;
	cn += (h[to] == id);
	for(int x : g[to]) {
		solve(x, cn, id);
	}
	cn -= (h[to] == id);
}

void go() {
	int n, r, q;
	cin >> n >> r >> q;
	for(int i = 1; i<= n; i++) {
		if(i == 1)
			cin >> h[i];
		else
			cin >> s[i] >> h[i];
		p[h[i]].pb(i);
		if(i > 1) g[s[i]].pb(i);
	}
	dfs(1);
	// tt = 0;
	// for(int i = 1; i <= r; i++) {
	// 	if(p[h[i]].size() >= B) {
	// 		kk[i] = ++tt;
	// 		solve(1, 0, i);
	// 	}
	// 	sort(all(d[i]));
	// }
	// while(q--) {
	// 	int r1, r2;
	// 	cin >> r1 >> r2;
	// 	if(p[r1].size() >= B) {
	// 		cout << cnt[kk[r1]][r2] << '\n';
	// 	}
	// 	else {
	// 		int ans = 0;
	// 		for(int x : p[r1]) {
	// 			int ll = lower_bound(all(d[r2]), in[x]) - d[r2].begin() - 1;
	// 			int rr = upper_bound(all(d[r2]), out[x]) - d[r2].begin() - 1;
	// 			ans += rr - ll;
	// 		}
	// 		cout << ans << '\n';
	// 	}
	// 	cout.flush();
	// }
}
 
signed main() {
	// #ifndef
	// freopen("file.in", "r", stdin);
	// freopen("file.out", "w", stdout);
	// #endif
	fast;
	int t = 1;
	// cin >> t;
	while(t--) {
		go();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 14416 KB Unexpected end of file - int32 expected
2 Incorrect 10 ms 14416 KB Unexpected end of file - int32 expected
3 Incorrect 7 ms 14416 KB Unexpected end of file - int32 expected
4 Incorrect 8 ms 14416 KB Unexpected end of file - int32 expected
5 Incorrect 9 ms 14416 KB Unexpected end of file - int32 expected
6 Incorrect 10 ms 14432 KB Unexpected end of file - int32 expected
7 Incorrect 9 ms 14404 KB Unexpected end of file - int32 expected
8 Incorrect 8 ms 14544 KB Unexpected end of file - int32 expected
9 Incorrect 9 ms 14820 KB Unexpected end of file - int32 expected
10 Incorrect 10 ms 14992 KB Unexpected end of file - int32 expected
11 Incorrect 13 ms 15312 KB Unexpected end of file - int32 expected
12 Incorrect 15 ms 15696 KB Unexpected end of file - int32 expected
13 Incorrect 16 ms 15536 KB Unexpected end of file - int32 expected
14 Incorrect 18 ms 16116 KB Unexpected end of file - int32 expected
15 Incorrect 21 ms 18052 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 19068 KB Unexpected end of file - int32 expected
2 Incorrect 30 ms 18120 KB Unexpected end of file - int32 expected
3 Incorrect 32 ms 20668 KB Unexpected end of file - int32 expected
4 Incorrect 19 ms 16208 KB Unexpected end of file - int32 expected
5 Incorrect 20 ms 17384 KB Unexpected end of file - int32 expected
6 Incorrect 26 ms 17456 KB Unexpected end of file - int32 expected
7 Incorrect 44 ms 18464 KB Unexpected end of file - int32 expected
8 Incorrect 55 ms 22700 KB Unexpected end of file - int32 expected
9 Incorrect 73 ms 24100 KB Unexpected end of file - int32 expected
10 Incorrect 69 ms 27964 KB Unexpected end of file - int32 expected
11 Incorrect 87 ms 24392 KB Unexpected end of file - int32 expected
12 Incorrect 103 ms 25704 KB Unexpected end of file - int32 expected
13 Incorrect 94 ms 25596 KB Unexpected end of file - int32 expected
14 Incorrect 109 ms 25696 KB Unexpected end of file - int32 expected
15 Incorrect 82 ms 29160 KB Unexpected end of file - int32 expected
16 Incorrect 79 ms 32520 KB Unexpected end of file - int32 expected
17 Incorrect 81 ms 31792 KB Unexpected end of file - int32 expected