跳到正文

个人记录

xxx

TMXtmx20121001约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年4月25日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int N=500001;

int t;
int n,m,d[N];
set<int> c[N];

inline void work(){
	cin >> n >> m;
	for (int i=1;i<=n;i++)
		c[i].clear();
	for (int i=1;i<=m;i++){
		int x,y;
		cin >> x >> y;
		if (c[x].find(y)!=c[x].end())
			continue;
		c[x].insert(y);
	}
	for (int i=1;i<=n;i++){
		for (auto y:c[i])
			cout << y << ' ';
		cout << '\n';
	}
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin >> t;
	while (t--) work();
	return 0;
}
原文