Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

AC代码

Posted by the_nameless_spectre at 2019-07-22 15:59:42 on Problem 1300
#include<bits/stdc++.h>

using namespace std;

vector<int> degree;
int E, V;
int M;
int main()
{
	ios_base::sync_with_stdio(false);
	string tmps;
	while(cin >> tmps && tmps != "ENDOFINPUT")
	{
		cin >> M >> V;
		E = 0;
		int u = 0, v;
		stringstream ss;//作为一名极度依赖C++的人...
		degree.clear();
		degree.resize(V, 0);
		getline(cin, tmps);
		while(getline(cin, tmps) && tmps != "END")
		{
			ss.clear();
			ss << tmps;
			while(ss >> v)
			{
				E++;
				degree[u]++;
				degree[v]++;
			}
			u++;
		}
		int flag = 0;
		for(int i = 0; i < V; i++)
		{
			if(degree[i] & 1)
			{
				flag++;
			}
		}
		if(flag == 0 && M == 0)
		{
			cout << "YES " << E << endl;
		}
		else
		{
			if(flag == 2 && (degree[M] & 1) && (degree[0] & 1) && M != 0)
			{
				cout << "YES " << E << endl;
			}
			else
			{
				cout << "NO" << endl;
			}
		}
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator