QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#796695#9743. 重心树JEdwardCompile Error//C++20786b2024-12-02 00:00:562024-12-02 00:00:56

Judging History

你现在查看的是最新测评结果

  • [2024-12-02 00:00:56]
  • 评测
  • [2024-12-02 00:00:56]
  • 提交

answer

#include<bits/stdc++.h
using std::cin, std::cout;
using ll = long long;
using u64 = unsigned long long;
using db = double;
const int N = 200005;
int anc[N];
int find(int x) {
	return anc[x] == x ? x : anc[x] = find(anc[x]);
}
void solve() {
	int n;
	cin >> n;
	std::vector<std::vector<int>> o(n + 1);
	for(int i = 1;i <= n;++i) {
		int c; cin >> c;
		o[i].resize(c);
		for(int & x : o[i]) cin >> x;
	}
	std::vector<std::pair<int, int>> ans;
	for(int i = n;i >= 1;--i) {
		anc[i] = i;
		for(int y : o[i]) {
			int z = find(y);
			ans.emplace_back(i, z);
			anc[z] = i;
		}
	}
	for(auto [x, y] : ans) {
		cout << x << ' ' << y << '\n';
	}
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0);
	int t;
	cin >> t;
	while(t--) {
		solve();
	}
}

詳細信息

answer.code:1:23: error: missing terminating > character
    1 | #include<bits/stdc++.h
      |                       ^