Blackness's blog

By Blackness, history, 8 years ago, In English

I'm afraid oyu8201 is cheating, his code:#include <bits/stdc++.h>

define fr(a, init, end) for(int a = init; a < end; ++a)

define add_wedge(a, b, c) to[z] = b; ant[z] = adj[a]; adj[a] = z; cost[z] = c; z++

define add_edge(a, b) to[z] = b; ant[z] = adj[a]; adj[a] = z++

define fre(i, u) for(int i = adj[u]; i != -1; i = ant[i])

define sc(a) scanf("%d", &a)

define debug(x) cerr << ">>> " << #x << " = " << x << endl;

define dbg(x) if(1) cerr << ">>> " << x << endl;

define _ << " , " <<

define endl '\n'

using namespace std;

typedef long long ll; typedef pair<int, int> ii;

const int N = int(1e6);

int col[N]; int to[N], ant[N], adj[N], z;

void dfs(int u) { fre(i, u) { if(col[to[i]] == -1) { col[to[i]] = col[u] ^ 1; dfs(to[i]); } } } int main() { ios::sync_with_stdio(false);cin.tie(NULL);

memset(col, -1, sizeof col);
memset(adj, -1, sizeof adj);
z = 0;

int n;
cin >> n;

int a, b;
vector<ii> p;

fr(i, 0, n)
{
    cin >> a >> b;
    --a, --b;
    add_edge(a, b);
    add_edge(b, a);
    p.push_back({a, b});
}

fr(i, 0, 2 * n)
{
    add_edge(i, i + 1);
    add_edge(i + 1, i);
    ++i;
}

fr(i, 0, 2 * n)
{
    if(col[i] == -1)
    {
        col[i] = 0;
        dfs(i);
    }
}

fr(i, 0, n)
{
    cout << col[p[i].first] + 1 << ' ' << col[p[i].second] + 1 << endl;
}

return 0;

}

my code: #include <bits/stdc++.h>

define fr(a, init, end) for(int a = init; a < end; ++a)

define add_wedge(a, b, c) to[z] = b; ant[z] = adj[a]; adj[a] = z; cost[z] = c; z++

define add_edge(a, b) to[z] = b; ant[z] = adj[a]; adj[a] = z++

define fre(i, u) for(int i = adj[u]; i != -1; i = ant[i])

define sc(a) scanf("%d", &a)

define debug(x) cerr << ">>> " << #x << " = " << x << endl;

define dbg(x) if(1) cerr << ">>> " << x << endl;

define _ << " , " <<

define endl '\n'

using namespace std;

typedef long long ll; typedef pair<int, int> ii;

const int N = int(1e6);

int col[N]; int to[N], ant[N], adj[N], z;

void dfs(int u) { fre(i, u) { if(col[to[i]] == -1) { col[to[i]] = col[u] ^ 1; dfs(to[i]); } } } int main() { ios::sync_with_stdio(false);cin.tie(NULL);

memset(col, -1, sizeof col);
memset(adj, -1, sizeof adj);
z = 0;

int n;
cin >> n;

int a, b;
vector<ii> p;

fr(i, 0, n)
{
    cin >> a >> b;
    --a, --b;
    add_edge(a, b);
    add_edge(b, a);
    p.push_back({a, b});
}

fr(i, 0, 2 * n)
{
    add_edge(i, i + 1);
    add_edge(i + 1, i);
    ++i;
}

fr(i, 0, 2 * n)
{
    if(col[i] == -1)
    {
        col[i] = 0;
        dfs(i);
    }
}

fr(i, 0, n)
{
    cout << col[p[i].first] + 1 << ' ' << col[p[i].second] + 1 << endl;
}

return 0;

}

  • Vote: I like it
  • -42
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it -6 Vote: I do not like it

My code and his code are exactly the same.

»
8 years ago, # |
Rev. 2   Vote: I like it +7 Vote: I do not like it

He didn't submit it during the contest so it's not really a big deal during practice, because you can look at anybody else's code.

It isn't really "cheating" it just doesn't have any effect on anybody. It would be a different story if he took your code during the contest.

»
8 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Sorry for copying your code. :(