Submission #6390103


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 B - Even Degrees
User priyam2k
Language C++ (GCC 5.4.1)
Score 0
Code Size 2762 Byte
Status CE

Compile Error

In file included from /usr/include/c++/5/unordered_set:35:0,
                 from ./Main.cpp:11:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \
  ^
./Main.cpp: In function ‘void dfs(long long int, long long int)’:
./Main.cpp:86:20: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
      for (int to : g[v]) {
                    ^
./Main.cpp:90:11: error: ‘class std::vector<std::pair<long long int, long long int> >’ has no member named ‘emplace_back’
       ans.emplace_back(v, par);
           ^
./Main.cpp:93:12: error: ‘class std::vector<std::pair<long long int, long long int> >’ has no member named ‘emplace_back’
        ans.emplace_back(par, v);
            ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:118:12: error: ‘class std::vector<std:...