QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#56944#2517. Critical StructuresSa3tElSefr#WA 72ms7644kbC++2.4kb2022-10-21 23:40:172022-10-21 23:40:18

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-21 23:40:18]
  • 评测
  • 测评结果:WA
  • 用时:72ms
  • 内存:7644kb
  • [2022-10-21 23:40:17]
  • 提交

answer

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1e3 + 5;
int t, n, m;
vector<int> g[N];
int d[N], low[N], T, cnt, id[N], mx;
bool vis[N], vis2[N], AP[N];
stack<int> nodes;
void dfs(int node, int par) {
    d[node] = low[node] = ++T;
    vis[node] = true;
    vis2[node] = true;
    int c = 0;
    nodes.push(node);
    for(auto &i : g[node]) {
        if(i == par)
            continue;
        if(!vis[i]) {
            c++;
            dfs(i, node);
            low[node] = min(low[node], low[i]);
        } else if(vis2[i])
            low[node] = min(low[node], d[i]);
    }
    if(low[node] == d[node]) {
        cnt++;
        int edges = 0;
        while(1) {
			edges++;
            int cur = nodes.top();
            id[cur] = cnt;
            vis2[cur] = false;
            nodes.pop();
            if(cur == node)
                break;
        }
        mx = max(mx, edges);
    }
}
void dfsAP(int node, int par) {
    d[node] = low[node] = ++T;
    vis[node] = true;
    int c = 0;
    for(auto &i : g[node]) {
        if(i == par)
            continue;
        if(!vis[i]) {
            c++;
            dfsAP(i, node);
            low[node] = min(low[node], low[i]);
            if(low[i] >= d[node])
                AP[node] = true;
        } else
            low[node] = min(low[node], d[i]);
    }
    if(node == 1)
        AP[node] = (c > 1);
}
void init() {
	T = 0;
	for(int i = 1;i <= n;i++)
		vis[i] = vis2[i] = AP[i] = 0;
}
pair<int, int> get(int p, int q) {
	int g = __gcd(p, q);
	return {p / g, q / g};
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> t;
    while(t--) {
		cin >> n >> m;
		for(int i = 1;i <= n;i++)
			g[i].clear();
		for(int i = 0;i < m;i++) {
			int u, v;
			cin >> u >> v;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		cnt = mx = 0;
		init();
		dfs(1, 1);
		init();
		dfsAP(1, 1);
		int bridges = 0;
		for(int i = 1;i <= n;i++) {
			for(auto j : g[i])
				if(id[i] != id[j])
					bridges++;
		}
		bridges /= 2;
		auto r = get(cnt + bridges, mx);
		cout << accumulate(AP + 1, AP + n + 1, 0) << " ";
		cout << bridges << " " << r.first << " " << r.second << '\n';
	}
    return 0;
}


詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 3660kb

input:

1
6 6
1 2
2 3
3 4
4 5
5 6
6 1

output:

0 0 1 6

result:

ok single line: '0 0 1 6'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

1
6 7
1 2
2 3
3 1
4 5
5 6
6 4
1 4

output:

2 1 1 1

result:

ok single line: '2 1 1 1'

Test #3:

score: -100
Wrong Answer
time: 72ms
memory: 7644kb

input:

10
6 6
1 2
2 3
3 4
4 5
5 6
6 1
5 4
1 2
2 3
3 4
4 5
5 7
1 2
1 3
3 4
4 5
5 3
1 4
1 5
13 16
1 2
1 6
1 3
1 7
3 7
4 6
4 5
5 6
5 7
7 8
8 9
7 10
10 11
12 13
10 12
10 13
10 11
1 2
2 3
2 4
3 5
4 5
4 6
6 7
7 8
6 8
8 9
8 10
3 3
1 2
2 3
3 1
44 66
1 5
1 12
1 33
2 27
2 31
2 32
2 35
2 37
2 40
3 6
3 30
3 44
4 20
4 ...

output:

0 0 1 6
3 4 9 1
1 1 3 4
4 5 11 6
4 4 9 4
0 0 1 3
8 9 19 35
0 0 1 1000
2 2 5 524
108 112 75 296

result:

wrong answer 2nd lines differ - expected: '3 4 4 1', found: '3 4 9 1'