Submission #6390107


Source Code Expand

Copy
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("no-stack-protector")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize("fast-math")
    #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <set>
    #include <map>
    #include <unordered_set>
    #include <unordered_map>
    #include <stdio.h>
    #include <cstdio>
    #include <math.h>
    #include <cmath>
    #include <string>
    #include <cstring>
    #include <queue>
    #include <deque>
    #include <random>
    #include <iomanip>
    #include <bitset>
                            
    using namespace std;
                            
    template<typename T> void uin(T &a, T b) {
        if (b < a) {
            a = b;
        }
    }
                            
    template<typename T> void uax(T &a, T b) {
        if (b > a) {
            a = b;
        }
    }
     
     
    #define int long long
    #define ghost signed
    #define left left228
    #define right right228
    #define prev prev228
    #define list list228
     
    const int N = 100 * 1000 + 228;
     
    namespace DSU
    {
    	int p[N], sz[N];
     
    	void init(int n) {
    		for (int i = 1; i <= n; ++i) {
    			p[i] = i;
    			sz[i] = 1;
    		}
    	}
     
    	int getp(int v) {
    		if (v == p[v]) return v;
    		p[v] = getp(p[v]);
    		return p[v];
    	}
     
    	bool join(int u, int v) {
    		u = getp(u);
    		v = getp(v);
    		if (u == v) return 0;
    		if (sz[u] < sz[v]) {
    			p[u] = v;
    			sz[v] += sz[u];
    		} else {
    			p[v] = u;
    			sz[u] += sz[v];
    		}
    		return 1;
    	}
    };
     
    vector<int> g[N];
    vector< pair<int, int> > ans;
    int deg[N];
     
    void dfs(int v, int par = -1) {
    	for (int to : g[v]) {
    		if (to != par) dfs(to, v);
    	}
    	if (deg[v]) {
    		ans.emplace_back(v, par);
    	} else {
    		if (par != -1) {
    			ans.emplace_back(par, v);
    			deg[par] ^= 1;
    		}
    	}
    }
     
    int a[100];
     
    ghost main() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
    	int n, m;
    	cin >> n >> m;
    	if (m & 1) {
    		cout << -1 << '\n';
    		return 0;
    	}
    	DSU::init(n);
    	for (int i = 0; i < m; ++i) {
    		int u, v;
    		cin >> u >> v;
    		if (DSU::join(u, v)) {
    			g[u].push_back(v);
    			g[v].push_back(u);
    		} else {
    			ans.emplace_back(u, v);
    			deg[u] ^= 1;
    		}
    	}
    	dfs(1);
    	for (auto p : ans) cout << p.first << ' ' << p.second << '\n';
        return 0;
    } // kek ;

Submission Info

Submission Time
Task A - XOR Circle
User priyam2k
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2762 Byte
Status RE
Exec Time 98 ms
Memory 4224 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
WA × 2
WA × 18
RE × 4
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt
Case Name Status Exec Time Memory
sample_01.txt WA 3 ms 3584 KB
sample_02.txt WA 3 ms 3584 KB
test_01.txt WA 3 ms 4224 KB
test_02.txt WA 3 ms 4224 KB
test_03.txt WA 3 ms 4224 KB
test_04.txt WA 2 ms 3584 KB
test_05.txt WA 3 ms 3584 KB
test_06.txt RE 97 ms 3712 KB
test_07.txt WA 3 ms 3584 KB
test_08.txt WA 2 ms 3584 KB
test_09.txt WA 2 ms 3584 KB
test_10.txt WA 2 ms 3584 KB
test_11.txt WA 2 ms 3584 KB
test_12.txt WA 2 ms 3584 KB
test_13.txt WA 2 ms 3584 KB
test_14.txt RE 98 ms 3840 KB
test_15.txt WA 3 ms 3584 KB
test_16.txt WA 2 ms 3584 KB
test_17.txt RE 98 ms 3584 KB
test_18.txt WA 3 ms 3584 KB
test_19.txt WA 2 ms 3712 KB
test_20.txt RE 97 ms 3968 KB