QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534258#5088. Two ChoreographiesBongoCatEnjoyerWA 0ms3828kbC++201.7kb2024-08-26 23:05:152024-08-26 23:05:15

Judging History

你现在查看的是最新测评结果

  • [2024-08-26 23:05:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3828kb
  • [2024-08-26 23:05:15]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define forn(i, n) for (ll i = 0; i < n; ++i)
#define forr(i, s, n) for (ll i = s; i < n; ++i)
#define fori(i, s, n) for (ll i = s; i > n; --i)
#define fora(i, n) for (auto i: n)
#define vi vector<int>
#define vll vector<ll>
#define prints(n) cout << (n) << " "
#define println(n) cout << (n) << "\n"
#define newl() cout << "\n"

const int MOD = 998244353;
// const int MOD = 1e9 + 7;

void solve() {
    ll n; cin >> n;

    vector<vector<ll>> adjv(n, vector<ll>());
    vector<set<ll>> adjs(n, set<ll>());
    forn(i, 2 * n - 3) {
        ll u, v; cin >> u >> v; u--; v--;

        adjv[u].push_back(v);
        adjv[v].push_back(u);

        adjs[u].insert(v);
        adjs[v].insert(u);
    }

    vector<tuple<ll, ll, ll>> s;
    forn(i, n) {
        ll fn = i;

        forn(j, adjv[fn].size()) {
            ll sn = adjv[fn][j];

            forn(k, adjv[sn].size()) {
                ll tn = adjv[sn][k];

                if (adjs[tn].find(fn) != adjs[tn].end()) {
                    vector<ll> v;
                    v.push_back(fn); v.push_back(sn); v.push_back(tn);
                    sort(begin(v), end(v));

                    s.push_back(make_tuple(v[0], v[1], v[2]));
                }
            }
        }

        if (s.size() >= 2) break;
    }

    auto [fa, fb, fc] = s[0];
    auto [sa, sb, sc] = s[1];

    println(3);
    prints(fa + 1); prints(fb + 1); println(fc + 1);
    prints(sa + 1); prints(sb + 1); println(sc + 1);
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3752kb

input:

4
1 2
1 3
1 4
2 3
2 4

output:

3
1 2 3
1 2 4

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

5
1 2
1 3
1 4
1 5
2 3
2 5
3 4

output:

3
1 2 3
1 2 5

result:

ok 

Test #3:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

7
1 2
3 4
5 6
5 2
3 1
6 1
4 2
4 5
2 6
3 6
1 5

output:

3
1 2 5
1 2 6

result:

ok 

Test #4:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

40
1 16
1 40
2 4
2 16
2 36
3 25
3 38
4 1
4 13
5 11
5 27
6 4
7 5
7 11
8 10
8 14
8 24
9 34
10 20
12 35
13 2
14 10
14 20
15 18
15 28
15 31
16 6
16 13
17 5
17 11
17 27
18 9
19 1
19 4
19 16
20 24
21 12
21 33
21 35
22 38
23 12
23 21
25 28
25 31
25 34
25 38
26 14
26 20
27 7
27 11
28 3
28 31
29 16
29 19
30 ...

output:

3
1 16 19
1 16 36

result:

ok 

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3596kb

input:

201
1 7
1 114
1 119
2 49
2 93
4 197
5 139
6 1
6 27
7 39
7 121
8 127
9 130
9 145
11 106
11 136
11 193
12 2
12 116
13 55
13 69
13 105
13 187
13 196
14 144
14 177
15 127
15 134
15 145
15 155
15 184
15 199
16 96
16 177
17 20
21 100
22 68
22 71
22 81
22 142
23 148
23 190
24 12
24 81
24 89
25 158
25 159
2...

output:

3
5 54 63
5 54 63

result:

wrong answer Wrong output - Identical cycle.