QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#44716#999. 边双连通分量Remakee#WA 3ms6460kbC++141.9kb2022-08-21 11:35:072022-08-21 11:35:09

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-21 11:35:09]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:6460kb
  • [2022-08-21 11:35:07]
  • 提交

answer

// Skyqwq
#include <bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;

template <typename T> bool inline chkMin(T &x, T y) { return (y < x) ? x = y, 1 : 0; }
template <typename T> bool inline chkMax(T &x, T y) { return (y > x) ? x = y, 1 : 0; }

template <typename T> void inline read(T &x) {
	x = 0; int f = 1; char s = getchar();
	while (s > '9' || s < '0') { if (s == '-') f = -1; s = getchar(); }
	while (s <= '9' && s >= '0') x = x * 10 + s - '0', s = getchar();
	x *= f;
}

const int N = 1e5 + 5, M = 5e5 + 5;

int n, m, A[M], B[M], f[N];

int find(int x) {
	return x == f[x] ? x : f[x] = find(f[x]);
}

void inline merge(int x, int y) {
	x = find(x), y = find(y);
	if (x == y) return ;
	f[x] = y;
}

bool st[M];

int head[N], numE = 1;

struct E{
	int next, v;
} e[M << 1];

void add(int u, int v) {
	e[++numE] = (E) { head[u], v };
	head[u] = numE;
}

int dfn[N], low[N], dfncnt;

void tarjan(int u, int la) {
	dfn[u] = low[u] = ++dfncnt;
	for (int i = head[u]; i; i = e[i].next) {
		int v = e[i].v;
		if ((i ^ 1) == la) continue;
		if (!dfn[v]) {
			tarjan(v, i);
			chkMin(low[u], low[v]);
			if (low[v] > dfn[u]) {
				st[i >> 1] = 1;
			}
		} else chkMin(low[u], dfn[v]);
	}
}

vector<int> b[N];

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++) f[i] = i;
	for (int i = 1; i <= m; i++) {
		int u, v; read(u), read(v);
		++u, ++v;
		A[i] = u, B[i] = v;
		add(u, v), add(v, u);
	}
	for (int i = 1; i <= n; i++) if (!dfn[i]) tarjan(i, 0);
	for (int i = 1; i <= m; i++)
		if (!st[i]) merge(A[i], B[i]);
	for (int i = 1; i <= n; i++) b[find(i)].pb(i);
	for (int i = 1; i <= n; i++) {
		if (find(i) == i) {
			cout << b[i].size() << " ";
			for (int v: b[i]) cout << v - 1 << " ";
			cout << endl;
		}
	}
	return 0;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 6460kb

input:

4 5
0 2
0 1
3 0
2 1
2 3

output:

4 0 1 2 3 

result:

wrong answer Integer 0 violates the range [1, 4]