Submission #294108

# Submission time Handle Problem Language Result Execution time Memory
294108 2020-09-08T15:28:24 Z 최은수(#5798) None (balkan16_acrobat) C++17
0 / 100
6 ms 7424 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
const int mx=300010;
vector<int>adj[mx];
int par[mx];
void dfs(int x,int p)
{
    par[x]=p;
    for(int&t:adj[x])
    {
        if(par[t]==0)
            dfs(t,p^3);
        else if(par[t]==p)
        {
            cout<<-1<<endl;
            exit(0);
        }
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    if(n%2==1)
        return cout<<-1<<endl,0;
    vector<pi>ev;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        ev.eb(u,v);
        if(u==v)
            return cout<<-1<<endl,0;
        adj[u].eb(v);
        adj[v].eb(u);
    }
    for(int i=0;i++<n;)
        if(par[i]==0)
            dfs(i,1);
    for(pi&t:ev)
        if(par[t.fi]==2)
            cout<<1<<' '<<t.fi<<' '<<t.se<<'\n';
    for(int i=1;i<n;i++)
        cout<<2<<' '<<i<<' '<<i+1<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7424 KB Integer 3 violates the range [1, 2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 7424 KB Integer 3 violates the range [1, 2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7424 KB Integer 3 violates the range [1, 2]
2 Halted 0 ms 0 KB -