Submission #6375849


Source Code Expand

#include <bits/stdc++.h>
#define inf 4294967295
#define MAXN 500100
#define LL long long
#define pi acos(-1)
#define MOD 332748118

using namespace std;

struct pp{
	int x,y;
} ans[MAXN];

int ot[MAXN],ne[MAXN],g[MAXN],e,d[MAXN],f[MAXN];

void add(int x,int y){
	ot[++e]=y,ne[e]=g[x],g[x]=e;
	ot[++e]=x,ne[e]=g[y],g[y]=e;	
}

int n,m;
set<int> a,b;

int main()
{
	scanf("%d%d",&n,&m);
	for (int i = 1; i <= m; ++i){
		int x,y;
		scanf("%d%d",&x,&y);	
		add(x,y);
		d[x]++,d[y]++;
	}
	for (int i = 1; i <= n; ++i) f[i] = 0;
	for (int i = 1; i <= n; ++i) if (d[i]%2) a.insert(i);else b.insert(i);
	int tot=0;
	set<int>::iterator it;
	int pp = 1;
	while (tot<m){
		it=b.begin();
		if (it==b.end()){
			pp = 0;
			break;
		}
		int x = *it;
		f[x] = 1;
		b.erase(x);
		//cout << x << " " << d[x] << endl;
		for (int p = g[x]; p; p = ne[p]){
			int y = ot[p];
			if (!f[y]){
				ans[++tot].x = x, ans[tot].y = y;
				if (d[y]%2){
					a.erase(y);d[y]--;
					b.insert(y);	
				} else {
					b.erase(y);d[y]--;
					a.insert(y);	
				}
			}
		}
	}
	if (!pp) puts("-1");
	else {
		for (int i = 1; i <= m; ++i) printf("%d %d\n",ans[i].x,ans[i].y);	
	}
	return 0;
}

Submission Info

Submission Time
Task B - Even Degrees
User ZzZZCHS
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1221 Byte
Status WA
Exec Time 100 ms
Memory 15616 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:26:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
./Main.cpp:29:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x,&y); 
                      ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 16
WA × 20
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt WA 80 ms 15616 KiB
02.txt WA 80 ms 15616 KiB
03.txt WA 85 ms 15616 KiB
04.txt WA 84 ms 15616 KiB
05.txt AC 80 ms 15616 KiB
06.txt WA 76 ms 13056 KiB
07.txt WA 73 ms 13056 KiB
08.txt WA 74 ms 13056 KiB
09.txt WA 73 ms 13056 KiB
10.txt AC 74 ms 13184 KiB
11.txt WA 54 ms 11008 KiB
12.txt WA 54 ms 11008 KiB
13.txt WA 54 ms 11008 KiB
14.txt WA 54 ms 11008 KiB
15.txt AC 54 ms 11008 KiB
16.txt WA 45 ms 10624 KiB
17.txt WA 45 ms 10624 KiB
18.txt WA 45 ms 10624 KiB
19.txt WA 45 ms 10624 KiB
20.txt AC 45 ms 10624 KiB
21.txt AC 52 ms 11264 KiB
22.txt AC 52 ms 11264 KiB
23.txt WA 39 ms 10496 KiB
24.txt AC 52 ms 11264 KiB
25.txt AC 40 ms 10496 KiB
26.txt AC 92 ms 15616 KiB
27.txt AC 97 ms 15616 KiB
28.txt WA 100 ms 15616 KiB
29.txt WA 98 ms 15616 KiB
30.txt AC 3 ms 8448 KiB
31.txt AC 2 ms 6400 KiB
32.txt AC 3 ms 8448 KiB
33.txt AC 3 ms 8448 KiB
34.txt WA 2 ms 6400 KiB
s1.txt AC 3 ms 8448 KiB
s2.txt AC 3 ms 8448 KiB