Submission #8873571


Source Code Expand

#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int N, M;
	int a, b;
	int count;
	int current;
	int ans = 0;
	cin >> N >> M;
	vector<bool> IsThrough(N, false);
	vector<vector<bool>> root(N, vector<bool>(N, false));
	vector<vector<int>> i_root(M, vector<int>(2, 0));
	queue<int> next;
	for (int i = 0; i < M; i++)
	{
		cin >> a >> b;
		i_root[i][0] = a - 1;
		i_root[i][1] = b - 1;
		root[i_root[i][0]][i_root[i][1]] = true;
		root[i_root[i][1]][i_root[i][0]] = true;
	}

	for (int i = 0; i < M; i++)
	{
		IsThrough = vector<bool>(N, false);
		root[i_root[i][0]][i_root[i][1]] = false;
		root[i_root[i][1]][i_root[i][0]] = false;
		next.push(0);
		count = 0;
		for (; !next.empty();)
		{
			current = next.front();
			next.pop();

			for (int j = 0; j < N; j++)
			{
				if (root[current][j] && !IsThrough[j])
				{
					IsThrough[j] = true;
					next.push(j);
				}
			}
			count++;
		}
		if (count <= N)
			ans++;

		root[i_root[i][0]][i_root[i][1]] = true;
		root[i_root[i][1]][i_root[i][0]] = true;
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Submission Info

Submission Time
Task C - Bridge
User SHU_M
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1423 Byte
Status AC
Exec Time 2 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_1.txt AC 1 ms 256 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt AC 1 ms 256 KB
subtask_1_12.txt AC 1 ms 256 KB
subtask_1_13.txt AC 1 ms 256 KB
subtask_1_14.txt AC 1 ms 256 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_16.txt AC 2 ms 256 KB
subtask_1_17.txt AC 1 ms 256 KB
subtask_1_2.txt AC 1 ms 256 KB
subtask_1_3.txt AC 1 ms 256 KB
subtask_1_4.txt AC 1 ms 256 KB
subtask_1_5.txt AC 1 ms 256 KB
subtask_1_6.txt AC 1 ms 256 KB
subtask_1_7.txt AC 1 ms 256 KB
subtask_1_8.txt AC 1 ms 256 KB
subtask_1_9.txt AC 1 ms 256 KB