Submission #371205


Source Code Expand

#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <complex>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;

const int N = 1e5 + 10;
int dist[N];
int len;

vector<int> G[N];
void dfs(int v, int p, int d){
	if (dist[v] > 0){
		len = d - dist[v];
		return;
	}
	dist[v] = d;
	for (auto nxt : G[v]){
		if (nxt == p) continue;
		dfs(nxt, v, d + 1);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(20);

	int n;
	cin >> n;
	rep(i, n){
		int a, b;
		cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int Min = 1e9;
	rep(i, n) Min = min(Min, (int)G[i].size());
	dfs(0, -1, 1);

	int Max = n - (len & 1);

	cout << Min << ' ' << Max << endl;

}

Submission Info

Submission Time
Task C - 最小カットと最大カット
User yuusune
Language C++11 (GCC 4.9.2)
Score 100
Code Size 1530 Byte
Status AC
Exec Time 104 ms
Memory 11356 KiB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 29
Set Name Test Cases
All scrambled_00.txt, scrambled_01.txt, scrambled_02.txt, scrambled_03.txt, scrambled_04.txt, scrambled_05.txt, scrambled_06.txt, scrambled_07.txt, scrambled_08.txt, scrambled_09.txt, scrambled_10.txt, scrambled_11.txt, scrambled_12.txt, scrambled_13.txt, scrambled_14.txt, scrambled_15.txt, scrambled_16.txt, scrambled_17.txt, scrambled_18.txt, scrambled_19.txt, scrambled_20.txt, scrambled_21.txt, scrambled_22.txt, scrambled_23.txt, scrambled_24.txt, scrambled_25.txt, scrambled_26.txt, scrambled_27.txt, scrambled_28.txt
Case Name Status Exec Time Memory
scrambled_00.txt AC 30 ms 3096 KiB
scrambled_01.txt AC 29 ms 3112 KiB
scrambled_02.txt AC 27 ms 3108 KiB
scrambled_03.txt AC 103 ms 11356 KiB
scrambled_04.txt AC 104 ms 11300 KiB
scrambled_05.txt AC 74 ms 8220 KiB
scrambled_06.txt AC 57 ms 6308 KiB
scrambled_07.txt AC 96 ms 10664 KiB
scrambled_08.txt AC 51 ms 5660 KiB
scrambled_09.txt AC 57 ms 6440 KiB
scrambled_10.txt AC 77 ms 7076 KiB
scrambled_11.txt AC 47 ms 4640 KiB
scrambled_12.txt AC 66 ms 6180 KiB
scrambled_13.txt AC 62 ms 6048 KiB
scrambled_14.txt AC 90 ms 6624 KiB
scrambled_15.txt AC 73 ms 5540 KiB
scrambled_16.txt AC 52 ms 4388 KiB
scrambled_17.txt AC 51 ms 4388 KiB
scrambled_18.txt AC 95 ms 6696 KiB
scrambled_19.txt AC 32 ms 3364 KiB
scrambled_20.txt AC 67 ms 5420 KiB
scrambled_21.txt AC 51 ms 4388 KiB
scrambled_22.txt AC 71 ms 5600 KiB
scrambled_23.txt AC 54 ms 4644 KiB
scrambled_24.txt AC 50 ms 4500 KiB
scrambled_25.txt AC 58 ms 4888 KiB
scrambled_26.txt AC 53 ms 4516 KiB
scrambled_27.txt AC 66 ms 5280 KiB
scrambled_28.txt AC 61 ms 5156 KiB