Submission #6374072


Source Code Expand

Copy
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,u[100005],U[100005];
vector<int> v[100005],e[100005];
void dfs(int x){
    U[x]=1;
    for(int i=0;i<v[x].size();++i){
        int z=v[x][i];
        if(U[z]) continue;
        dfs(z);
    }
    int cnt=0;
    for(int i=0;i<e[x].size();++i)if(u[e[x][i]]!=1)++cnt;
    if(cnt&1)--cnt;
    for(int i=0;i<e[x].size();++i){
        if(u[e[x][i]]==2){
            u[e[x][i]]=1;
            --cnt;
            printf("%d %d\n",x,v[x][i]);
        }
    }
    for(int i=0;i<e[x].size();++i){
        if(u[e[x][i]]==0&&cnt){
            u[e[x][i]]=1;
            --cnt;
            printf("%d %d\n",x,v[x][i]);
            continue;
        }
        u[e[x][i]]=2;
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].pb(y),v[y].pb(x);
        e[x].pb(i),e[y].pb(i);
    }
    if(m&1){
        puts("-1");
        return 0;
    }
    dfs(1);
    //system("pause");
    return 0;
}

Submission Info

Submission Time
Task B - Even Degrees
User skyline
Language C++14 (GCC 5.4.1)
Score 700
Code Size 2335 Byte
Status AC
Exec Time 81 ms
Memory 20864 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:96:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
./Main.cpp:99:28: 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 700 / 700
Status
AC × 2
AC × 36
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 AC 77 ms 13184 KB
02.txt AC 81 ms 13184 KB
03.txt AC 79 ms 13184 KB
04.txt AC 79 ms 13184 KB
05.txt AC 56 ms 11264 KB
06.txt AC 72 ms 13440 KB
07.txt AC 73 ms 13312 KB
08.txt AC 74 ms 13184 KB
09.txt AC 71 ms 13312 KB
10.txt AC 46 ms 9088 KB
11.txt AC 53 ms 9856 KB
12.txt AC 53 ms 9856 KB
13.txt AC 53 ms 9856 KB
14.txt AC 52 ms 9856 KB
15.txt AC 34 ms 7808 KB
16.txt AC 44 ms 8576 KB
17.txt AC 44 ms 8576 KB
18.txt AC 44 ms 8576 KB
19.txt AC 43 ms 8576 KB
20.txt AC 28 ms 7168 KB
21.txt AC 37 ms 8320 KB
22.txt AC 37 ms 8320 KB
23.txt AC 37 ms 8320 KB
24.txt AC 37 ms 8192 KB
25.txt AC 22 ms 7168 KB
26.txt AC 47 ms 11136 KB
27.txt AC 46 ms 11136 KB
28.txt AC 77 ms 20864 KB
29.txt AC 78 ms 20864 KB
30.txt AC 4 ms 4992 KB
31.txt AC 4 ms 4992 KB
32.txt AC 4 ms 4992 KB
33.txt AC 4 ms 4992 KB
34.txt AC 4 ms 4992 KB
s1.txt AC 4 ms 4992 KB
s2.txt AC 4 ms 4992 KB