Submission #2561228


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ab(int x){return x>0?x:-x;}
vector<int> G[100005];
int f[100005];
int dfs(int x,int fa)
{
	f[x]=-1;
	for(int v:G[x])
		if(v!=fa)
			f[x]-=dfs(v,x);
	return f[x];
}
int main()
{
	ios::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	for(int i=1,u,v;i<=m;i++)
		cin>>u>>v,G[u].push_back(v),G[v].push_back(u);
	
	if(!dfs(1,0)) {
		ll ans=0;
		for(int i=1;i<=n;i++)
			ans+=ab(f[i]);
		cout<<ans<<endl;
	} else 
		cout<<-1<<endl;
	return 0;
}

Submission Info

Submission Time
Task F - Namori
User j31234
Language C++14 (GCC 5.4.1)
Score 1500
Code Size 532 Byte
Status RE
Exec Time 2114 ms
Memory 268672 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 1500 / 1500 0 / 700
Status
AC × 2
RE × 2
AC × 20
AC × 20
TLE × 23
RE × 23
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
Subtask1 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt, 2_16.txt, 2_17.txt, 2_18.txt, 2_19.txt, 2_20.txt, 2_21.txt, 2_22.txt, 2_23.txt, 2_24.txt, 2_25.txt, 2_26.txt, 2_27.txt, 2_28.txt, 2_29.txt, 2_30.txt, 2_31.txt, 2_32.txt, 2_33.txt, 2_34.txt, 2_35.txt, 2_36.txt, 2_37.txt, 2_38.txt, 2_39.txt, 2_40.txt, 2_41.txt, 2_42.txt, 2_43.txt
Case Name Status Exec Time Memory
0_00.txt AC 2 ms 2560 KB
0_01.txt AC 2 ms 2560 KB
0_02.txt RE 230 ms 264704 KB
0_03.txt RE 230 ms 264704 KB
1_00.txt AC 2 ms 2560 KB
1_01.txt AC 41 ms 10624 KB
1_02.txt AC 34 ms 7552 KB
1_03.txt AC 28 ms 6520 KB
1_04.txt AC 39 ms 8320 KB
1_05.txt AC 39 ms 8064 KB
1_06.txt AC 39 ms 8064 KB
1_07.txt AC 39 ms 7552 KB
1_08.txt AC 39 ms 8448 KB
1_09.txt AC 34 ms 6528 KB
1_10.txt AC 35 ms 6272 KB
1_11.txt AC 37 ms 6272 KB
1_12.txt AC 38 ms 6144 KB
1_13.txt AC 39 ms 6528 KB
1_14.txt AC 38 ms 6272 KB
1_15.txt AC 38 ms 6144 KB
1_16.txt AC 38 ms 6144 KB
1_17.txt AC 38 ms 6144 KB
2_00.txt RE 228 ms 264704 KB
2_01.txt RE 515 ms 268288 KB
2_02.txt RE 557 ms 268504 KB
2_03.txt TLE 2104 ms 10616 KB
2_04.txt RE 606 ms 268416 KB
2_05.txt RE 640 ms 268288 KB
2_06.txt RE 663 ms 268288 KB
2_07.txt RE 609 ms 268416 KB
2_08.txt RE 651 ms 268288 KB
2_09.txt TLE 2104 ms 6656 KB
2_10.txt TLE 2104 ms 6400 KB
2_11.txt RE 1587 ms 268416 KB
2_12.txt TLE 2104 ms 6272 KB
2_13.txt RE 701 ms 268288 KB
2_14.txt TLE 2114 ms 179200 KB
2_15.txt TLE 2105 ms 32384 KB
2_16.txt TLE 2104 ms 8832 KB
2_17.txt RE 378 ms 268288 KB
2_18.txt RE 230 ms 264704 KB
2_19.txt RE 513 ms 268412 KB
2_20.txt TLE 2104 ms 10360 KB
2_21.txt RE 519 ms 268288 KB
2_22.txt RE 589 ms 268416 KB
2_23.txt RE 626 ms 268416 KB
2_24.txt RE 669 ms 268288 KB
2_25.txt RE 587 ms 268672 KB
2_26.txt RE 651 ms 268288 KB
2_27.txt TLE 2104 ms 13184 KB
2_28.txt RE 775 ms 268416 KB
2_29.txt TLE 2104 ms 6912 KB
2_30.txt TLE 2104 ms 6272 KB
2_31.txt RE 820 ms 268288 KB
2_32.txt TLE 2112 ms 143616 KB
2_33.txt TLE 2104 ms 19840 KB
2_34.txt TLE 2107 ms 65024 KB
2_35.txt TLE 2105 ms 35968 KB
2_36.txt TLE 2104 ms 7288 KB
2_37.txt TLE 2104 ms 8184 KB
2_38.txt TLE 2104 ms 8184 KB
2_39.txt TLE 2104 ms 7416 KB
2_40.txt TLE 2104 ms 7416 KB
2_41.txt TLE 2104 ms 7672 KB
2_42.txt TLE 2104 ms 7544 KB
2_43.txt TLE 2104 ms 7288 KB