Submission #1792475


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
//typedef vector<edge> edges;
//vector<edges> G;

vector<edge> edges;
int graph[60][60];

bool vis[60];
int n, m;

void dfs(int v) {
	if (vis[v])return;
	vis[v] = 1;
	FORI(0, n) {
		if (graph[v][i]) {

			dfs(i);
		}
	}
}
int main(){
	cin >> n >> m;
	FORI(0, m) {
		int x, y;
		cin >> x >> y; x--; y--;
		edges.push_back(edge(x , y ));
		graph[x][y] = 1; graph[y][x] = 1;

	}
	int cnt = 0;
	FORI(0, m) {
		edge e = edges[i];
		graph[e.from][e.to] = graph[e.to][e.from] = 0;
		memset(vis, 0, sizeof(vis));
		dfs(0);
		bool connected=true;
		FORJ(0, n) {
			if (!vis[j])connected = false;
		}
		if (!connected)cnt++;
		graph[e.from][e.to] = graph[e.to][e.from] =  1;



	}
	cout << cnt << endl;
	return 0;
}

Submission Info

Submission Time
Task C - Bridge
User cypher512
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1673 Byte
Status AC
Exec Time 1 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 1 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