[Offer收割]编程练习赛14 register

Ended

Participants:574

Verdict:Accepted
Score:100 / 100
Submitted:2017-04-16 13:31:43

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
const int N = 100021;
typedef long long ll;
int mod = 1000000007;
int pre[N];
int fa[N], son[N];
int main()
{
    //freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    int n;
    while (~scanf("%d", &n))
    {
        int x, y, ans = -1;
        memset(pre, 0, sizeof(pre));
        for (int i = 0; i < n; i++)
        {
            scanf("%d%d", &x, &y);
            fa[i] = x;
            son[i] = y;
            if (pre[y] != 0)
            {
                ans = i;
            }else
                pre[y] = x;
        }
        x = y = -1;
        if (ans != -1)
        {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX