Submission #6373442


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int i,j,k=0;
    int deg[200005]={0};
    vector<int> a[n+5];
    for(i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
        deg[x]++;
        deg[y]++;
    }
    for(i=1;i<=n;i++){
        if(deg[i]%2){
            
            cout<<"-1";
            return 0;
        }
    }
    vector<pair<int,int>> v;
    for(i=1;i<=n;i++){
        if(deg[i]%2==0 && deg[i]>0){
            for(j=0;j<a[i].size();j++){
                v.push_back({i,a[i][j]});
                deg[i]--;
                deg[a[i][j]]--;
            }
        }
    }
    for(i=1;i<=n;i++){
        if(deg[i]>0){
            
            cout<<"-1";
            return 0;
        }
    }
    for(auto tt:v){
        cout<<tt.first<<' '<<tt.second<<"\n";
    }

    
    
}

Submission Info

Submission Time
Task B - Even Degrees
User priyam2k
Language C++14 (GCC 5.4.1)
Score 0
Code Size 941 Byte
Status WA
Exec Time 75 ms
Memory 7672 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 11
WA × 25
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 73 ms 6528 KB
02.txt WA 72 ms 6528 KB
03.txt WA 72 ms 6528 KB
04.txt WA 75 ms 6528 KB
05.txt AC 72 ms 6528 KB
06.txt WA 72 ms 4352 KB
07.txt WA 70 ms 4352 KB
08.txt WA 70 ms 4352 KB
09.txt WA 70 ms 4352 KB
10.txt AC 70 ms 4352 KB
11.txt WA 58 ms 2688 KB
12.txt WA 56 ms 2688 KB
13.txt WA 56 ms 2688 KB
14.txt WA 56 ms 2688 KB
15.txt AC 57 ms 2688 KB
16.txt WA 50 ms 2176 KB
17.txt WA 50 ms 2176 KB
18.txt WA 50 ms 2176 KB
19.txt WA 50 ms 2176 KB
20.txt AC 50 ms 2176 KB
21.txt WA 44 ms 2176 KB
22.txt WA 44 ms 2176 KB
23.txt WA 44 ms 2176 KB
24.txt WA 44 ms 2176 KB
25.txt AC 44 ms 2176 KB
26.txt AC 71 ms 6528 KB
27.txt AC 71 ms 6528 KB
28.txt WA 73 ms 7672 KB
29.txt WA 74 ms 7672 KB
30.txt WA 1 ms 1024 KB
31.txt AC 1 ms 1024 KB
32.txt WA 2 ms 1024 KB
33.txt AC 2 ms 1024 KB
34.txt WA 1 ms 1024 KB
s1.txt AC 2 ms 1024 KB
s2.txt AC 1 ms 1024 KB