QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#507960#7636. Fair ElectionspandapythonerTL 3939ms5708kbC++233.2kb2024-08-07 01:17:222024-08-07 01:17:23

Judging History

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

  • [2024-08-07 01:17:23]
  • 评测
  • 测评结果:TL
  • 用时:3939ms
  • 内存:5708kb
  • [2024-08-07 01:17:22]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;


using ll = long long;

#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, n) for(int i = 0; i < n; i += 1)
#define len(a) ((int)(a).size())


const ll inf = 1e18;
mt19937 rnd(234);


int32_t main() {
    if (1) {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }
    int n;
    cin >> n;
    vector<vector<int>> p(n);
    rep(i, n) {
        p[i].resize(3);
        rep(j, 3) {
            cin >> p[i][j];
            --p[i][j];
        }
    }
    vector<vector<int>> pos(n);
    rep(i, n) {
        pos[i].resize(3);
        rep(j, 3) {
            pos[i][p[i][j]] = j;
        }
    }
    vector<vector<pair<int, int>>> dp(n + 1);
    for (int x = 0; x <= n; x += 1) {
        if (n - 2 * x > 0) {
            dp[x].push_back(make_pair(0, 2));
        }
        if (max(0, n - 2 * x) <= x) {
            dp[x].push_back(make_pair(max(0, n - 2 * x), 0));
        }
        int val = max({ x + 1, (n - x + 1) / 2 });
        if (val <= n - x) {
            dp[x].push_back(make_pair(val, 1));
        }
        dp[x].push_back(make_pair(10 * n + 10000, -1));
    }
    for (int cnt = n - 1; cnt >= 0; cnt -= 1) {
        vector<vector<pair<int, int>>> ndp(cnt + 1);
        for (int x = 0; x <= cnt; x += 1) {
            auto& a = dp[x + 1];
            auto& b = dp[x];
            auto c = dp[x];
            for (auto& f : c) f.first -= 1;
            c[0].first = max(c[0].first, 0);
            if (len(c) >= 2 and c[0].first == c[1].first) c.erase(c.begin());
            int i = 0, j = 0, k = 0;
            int last_min = -1;
            int cur_pos = 0;
            int vala = -1, valb = -1, valc = -1;
            while (i < len(a) - 1 or j < len(b) - 1 or k < len(c) - 1) {
                cur_pos = min({ a[i].first, b[j].first, c[k].first });
                if (cur_pos > cnt - x) break;
                if (a[i].first == cur_pos) {
                    vala = a[i].second;
                    ++i;
                }
                if (b[j].first == cur_pos) {
                    valb = b[j].second;
                    ++j;
                }
                if (c[k].first == cur_pos) {
                    valc = c[k].second;
                    ++k;
                }
                int mn = vala;
                if (mn == -1 or (valb != -1 and pos[cnt][mn] > pos[cnt][valb])) {
                    mn = valb;
                }
                if (mn == -1 or (valc != -1 and pos[cnt][mn] > pos[cnt][valc])) {
                    mn = valc;
                }
                if (mn != last_min) {
                    ndp[x].push_back(make_pair(cur_pos, mn));
                    last_min = mn;
                }
            }
            ndp[x].push_back(make_pair(10 * n + 10000, -1));
            // assert(len(ndp[x]) <= 4);
        }
        dp.swap(ndp);
    }
    assert(!dp.empty() and !dp[0].empty());
    int result = -1;
    for (auto [cur_pos, cur_val] : dp[0]) {
        if (cur_pos <= 0) {
            result = cur_val;
        }
    }
    cout << result + 1 << "\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3 2 1
1 2 3
2 1 3

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

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

output:

3

result:

ok 1 number(s): "3"

Test #6:

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

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

input:

20
1 2 3
2 3 1
1 3 2
3 1 2
2 1 3
1 2 3
3 2 1
1 2 3
1 2 3
3 2 1
3 2 1
3 1 2
2 3 1
1 2 3
2 1 3
3 2 1
3 2 1
1 3 2
1 3 2
3 2 1

output:

1

result:

ok 1 number(s): "1"

Test #8:

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

input:

20
3 2 1
3 1 2
1 2 3
1 3 2
1 3 2
1 2 3
3 1 2
1 3 2
3 2 1
1 3 2
2 1 3
3 1 2
2 3 1
2 1 3
2 3 1
3 1 2
3 1 2
2 1 3
3 1 2
1 2 3

output:

1

result:

ok 1 number(s): "1"

Test #9:

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

input:

20
1 2 3
2 3 1
2 1 3
2 1 3
1 3 2
3 1 2
2 3 1
1 3 2
3 1 2
1 2 3
1 2 3
3 2 1
3 1 2
1 2 3
3 2 1
1 2 3
2 3 1
3 1 2
3 2 1
3 2 1

output:

3

result:

ok 1 number(s): "3"

Test #10:

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

input:

20
3 1 2
3 2 1
1 2 3
1 3 2
1 3 2
2 3 1
1 3 2
2 3 1
1 2 3
3 2 1
1 2 3
3 2 1
1 2 3
1 2 3
3 2 1
2 3 1
2 3 1
1 2 3
2 1 3
2 1 3

output:

1

result:

ok 1 number(s): "1"

Test #11:

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

input:

20
2 1 3
2 1 3
3 1 2
3 2 1
2 1 3
1 2 3
2 3 1
3 1 2
3 1 2
2 3 1
3 2 1
1 3 2
2 1 3
2 1 3
1 2 3
2 3 1
2 3 1
3 2 1
2 1 3
1 3 2

output:

2

result:

ok 1 number(s): "2"

Test #12:

score: 0
Accepted
time: 3921ms
memory: 5496kb

input:

10000
1 2 3
2 3 1
1 3 2
3 1 2
2 1 3
1 2 3
3 2 1
1 2 3
1 2 3
3 2 1
3 2 1
3 1 2
2 3 1
1 2 3
2 1 3
3 2 1
3 2 1
1 3 2
1 3 2
3 2 1
3 2 1
3 1 2
1 2 3
1 3 2
1 3 2
1 2 3
3 1 2
1 3 2
3 2 1
1 3 2
2 1 3
3 1 2
2 3 1
2 1 3
2 3 1
3 1 2
3 1 2
2 1 3
3 1 2
1 2 3
1 2 3
2 3 1
2 1 3
2 1 3
1 3 2
3 1 2
2 3 1
1 3 2
3 1 2
...

output:

3

result:

ok 1 number(s): "3"

Test #13:

score: 0
Accepted
time: 3870ms
memory: 5704kb

input:

10000
2 1 3
1 3 2
3 2 1
3 1 2
1 3 2
2 1 3
2 3 1
1 3 2
1 3 2
2 1 3
3 2 1
3 1 2
3 1 2
3 1 2
2 3 1
1 2 3
3 2 1
2 1 3
3 2 1
3 1 2
2 1 3
1 2 3
2 1 3
2 1 3
2 1 3
2 1 3
2 3 1
2 3 1
3 2 1
3 2 1
3 1 2
3 2 1
1 2 3
1 2 3
1 2 3
2 3 1
1 3 2
1 2 3
2 3 1
1 3 2
2 1 3
2 3 1
2 3 1
3 1 2
1 3 2
3 1 2
3 2 1
1 2 3
1 3 2
...

output:

3

result:

ok 1 number(s): "3"

Test #14:

score: 0
Accepted
time: 3906ms
memory: 5480kb

input:

10000
3 2 1
3 1 2
3 2 1
3 2 1
3 1 2
1 3 2
3 1 2
1 3 2
2 3 1
1 3 2
3 1 2
3 2 1
3 1 2
1 2 3
3 2 1
3 1 2
3 1 2
1 2 3
2 3 1
3 1 2
3 2 1
3 2 1
3 2 1
2 3 1
3 1 2
3 1 2
1 2 3
3 2 1
3 1 2
3 1 2
1 2 3
2 3 1
3 1 2
2 1 3
1 2 3
2 3 1
2 3 1
1 2 3
3 1 2
2 1 3
1 3 2
1 2 3
1 2 3
1 2 3
1 3 2
3 1 2
1 2 3
2 1 3
3 2 1
...

output:

1

result:

ok 1 number(s): "1"

Test #15:

score: 0
Accepted
time: 3883ms
memory: 5412kb

input:

10000
1 2 3
3 2 1
2 1 3
2 1 3
2 1 3
1 3 2
3 2 1
1 2 3
3 2 1
2 3 1
1 2 3
1 3 2
2 1 3
3 1 2
1 2 3
2 3 1
1 2 3
2 1 3
2 1 3
2 3 1
2 3 1
2 1 3
1 3 2
1 2 3
2 1 3
1 2 3
1 3 2
2 3 1
1 2 3
2 3 1
1 3 2
1 2 3
2 3 1
3 1 2
2 3 1
3 1 2
3 1 2
2 1 3
3 2 1
3 2 1
3 2 1
3 1 2
2 1 3
1 2 3
3 1 2
2 3 1
2 1 3
3 2 1
2 3 1
...

output:

2

result:

ok 1 number(s): "2"

Test #16:

score: 0
Accepted
time: 3895ms
memory: 5500kb

input:

10000
1 2 3
3 1 2
3 2 1
1 2 3
2 3 1
3 1 2
3 1 2
3 1 2
2 1 3
2 1 3
3 1 2
3 2 1
2 1 3
1 3 2
1 3 2
1 2 3
2 1 3
1 3 2
2 1 3
1 3 2
1 3 2
1 3 2
1 3 2
1 3 2
1 3 2
1 3 2
2 3 1
1 2 3
2 1 3
1 2 3
1 3 2
1 2 3
2 3 1
1 2 3
3 2 1
2 1 3
2 3 1
2 1 3
1 2 3
1 2 3
2 1 3
1 3 2
3 2 1
3 2 1
3 2 1
1 2 3
3 2 1
3 2 1
3 1 2
...

output:

2

result:

ok 1 number(s): "2"

Test #17:

score: 0
Accepted
time: 3880ms
memory: 5500kb

input:

10000
2 1 3
1 3 2
3 2 1
2 1 3
1 3 2
3 1 2
1 2 3
3 2 1
2 3 1
1 2 3
2 1 3
1 2 3
1 3 2
3 2 1
1 2 3
2 1 3
2 1 3
2 1 3
3 2 1
2 3 1
1 2 3
2 3 1
3 1 2
3 2 1
1 3 2
1 2 3
1 3 2
3 1 2
2 3 1
3 2 1
2 3 1
3 1 2
3 2 1
2 1 3
3 1 2
3 1 2
3 2 1
1 3 2
3 1 2
2 3 1
2 3 1
1 3 2
2 1 3
3 1 2
3 2 1
1 3 2
1 3 2
2 1 3
2 1 3
...

output:

1

result:

ok 1 number(s): "1"

Test #18:

score: 0
Accepted
time: 3905ms
memory: 5484kb

input:

10000
3 1 2
2 3 1
3 2 1
2 3 1
2 1 3
3 1 2
2 1 3
3 1 2
3 2 1
3 2 1
3 2 1
1 2 3
2 3 1
2 3 1
3 1 2
3 1 2
2 1 3
2 1 3
3 2 1
1 2 3
3 2 1
3 1 2
1 2 3
3 1 2
1 3 2
2 3 1
1 2 3
1 3 2
2 1 3
2 3 1
1 3 2
1 3 2
2 3 1
2 3 1
3 1 2
2 3 1
3 1 2
2 3 1
2 1 3
3 1 2
1 2 3
1 2 3
1 2 3
1 2 3
2 3 1
1 2 3
3 1 2
2 1 3
2 1 3
...

output:

1

result:

ok 1 number(s): "1"

Test #19:

score: 0
Accepted
time: 3933ms
memory: 5468kb

input:

10000
3 2 1
1 2 3
3 2 1
3 1 2
3 1 2
2 3 1
1 2 3
1 3 2
1 3 2
2 3 1
1 3 2
1 3 2
1 2 3
3 2 1
3 1 2
2 1 3
2 1 3
2 1 3
2 3 1
3 1 2
1 3 2
3 2 1
3 2 1
3 2 1
2 3 1
1 2 3
2 3 1
1 2 3
1 3 2
1 3 2
3 1 2
1 2 3
2 3 1
1 2 3
3 2 1
2 1 3
2 3 1
2 1 3
1 3 2
3 1 2
3 1 2
3 1 2
3 1 2
3 1 2
3 1 2
3 1 2
3 2 1
3 2 1
3 1 2
...

output:

3

result:

ok 1 number(s): "3"

Test #20:

score: 0
Accepted
time: 3921ms
memory: 5492kb

input:

10000
3 1 2
1 2 3
1 2 3
2 3 1
3 1 2
1 2 3
2 3 1
3 2 1
1 2 3
3 2 1
3 2 1
3 2 1
3 1 2
1 3 2
2 1 3
3 1 2
3 2 1
3 1 2
2 3 1
3 1 2
1 2 3
3 1 2
2 1 3
1 2 3
3 1 2
1 2 3
1 3 2
3 2 1
2 1 3
3 2 1
2 3 1
3 1 2
2 3 1
1 2 3
1 3 2
3 2 1
3 1 2
1 2 3
3 1 2
3 1 2
3 1 2
2 3 1
2 3 1
3 2 1
2 1 3
2 3 1
2 1 3
1 2 3
2 3 1
...

output:

3

result:

ok 1 number(s): "3"

Test #21:

score: 0
Accepted
time: 3924ms
memory: 5476kb

input:

10000
2 1 3
1 3 2
3 1 2
3 2 1
3 1 2
2 3 1
2 3 1
1 2 3
2 1 3
1 3 2
1 2 3
1 3 2
3 2 1
3 2 1
3 1 2
2 1 3
2 3 1
2 3 1
3 2 1
1 3 2
2 1 3
3 2 1
3 2 1
2 3 1
2 1 3
3 2 1
1 3 2
3 2 1
1 3 2
1 2 3
3 1 2
2 3 1
3 1 2
2 1 3
1 3 2
3 2 1
1 3 2
3 2 1
1 3 2
3 2 1
2 3 1
1 3 2
3 1 2
3 2 1
3 1 2
3 1 2
1 2 3
2 3 1
3 2 1
...

output:

1

result:

ok 1 number(s): "1"

Test #22:

score: 0
Accepted
time: 3920ms
memory: 5472kb

input:

10000
3 2 1
3 1 2
3 2 1
2 1 3
3 2 1
1 3 2
3 2 1
2 1 3
1 3 2
1 3 2
1 3 2
2 3 1
3 1 2
3 2 1
2 3 1
2 1 3
1 2 3
1 3 2
1 2 3
1 2 3
1 3 2
2 1 3
1 2 3
2 3 1
2 1 3
2 1 3
2 1 3
3 1 2
1 2 3
3 1 2
2 3 1
3 1 2
1 3 2
1 3 2
3 2 1
2 1 3
2 1 3
3 1 2
3 2 1
3 2 1
3 2 1
3 1 2
3 2 1
2 1 3
3 1 2
2 1 3
1 3 2
3 1 2
1 2 3
...

output:

1

result:

ok 1 number(s): "1"

Test #23:

score: 0
Accepted
time: 3922ms
memory: 5380kb

input:

10000
2 3 1
2 1 3
2 3 1
2 3 1
3 2 1
2 3 1
1 2 3
2 3 1
1 2 3
3 1 2
1 2 3
1 3 2
3 1 2
3 2 1
3 2 1
3 1 2
1 2 3
3 2 1
2 3 1
2 3 1
1 3 2
1 3 2
2 1 3
3 1 2
2 3 1
2 3 1
2 3 1
1 3 2
1 3 2
1 3 2
2 3 1
3 1 2
2 1 3
2 3 1
3 2 1
3 2 1
2 3 1
1 2 3
2 1 3
2 3 1
1 2 3
2 3 1
1 2 3
1 3 2
3 2 1
3 2 1
1 2 3
3 2 1
3 1 2
...

output:

1

result:

ok 1 number(s): "1"

Test #24:

score: 0
Accepted
time: 3904ms
memory: 5412kb

input:

10000
1 3 2
2 1 3
2 1 3
3 2 1
1 2 3
3 1 2
3 1 2
3 1 2
3 1 2
1 2 3
2 1 3
1 3 2
3 2 1
3 1 2
1 3 2
1 2 3
1 3 2
2 3 1
3 1 2
3 2 1
1 2 3
3 2 1
3 2 1
1 3 2
1 2 3
3 2 1
2 3 1
3 2 1
2 3 1
3 2 1
1 2 3
1 3 2
2 3 1
3 1 2
2 3 1
2 3 1
1 3 2
3 1 2
2 3 1
3 2 1
2 1 3
2 3 1
1 3 2
3 2 1
2 3 1
2 3 1
1 2 3
2 1 3
2 1 3
...

output:

3

result:

ok 1 number(s): "3"

Test #25:

score: 0
Accepted
time: 3914ms
memory: 5444kb

input:

10000
2 1 3
2 3 1
3 2 1
1 2 3
3 1 2
2 1 3
2 3 1
1 3 2
1 2 3
2 3 1
3 1 2
3 2 1
1 2 3
2 3 1
3 1 2
3 1 2
2 3 1
1 2 3
1 2 3
3 1 2
2 3 1
2 1 3
1 3 2
1 3 2
2 3 1
1 2 3
2 3 1
2 1 3
3 2 1
1 2 3
1 2 3
1 2 3
1 3 2
2 1 3
1 2 3
1 3 2
1 2 3
1 2 3
3 2 1
2 1 3
2 1 3
1 3 2
1 3 2
1 2 3
3 2 1
2 1 3
3 1 2
1 3 2
1 3 2
...

output:

1

result:

ok 1 number(s): "1"

Test #26:

score: 0
Accepted
time: 3917ms
memory: 5412kb

input:

10000
2 1 3
3 1 2
1 2 3
2 1 3
3 1 2
1 3 2
2 1 3
3 2 1
3 1 2
1 3 2
1 3 2
3 2 1
2 1 3
1 2 3
3 1 2
1 2 3
2 1 3
1 3 2
1 2 3
2 3 1
3 1 2
2 1 3
2 3 1
2 1 3
2 3 1
3 2 1
2 3 1
1 3 2
1 2 3
3 1 2
2 3 1
1 2 3
1 3 2
3 2 1
3 1 2
2 1 3
3 2 1
1 2 3
1 3 2
2 3 1
3 1 2
1 2 3
3 1 2
1 3 2
3 1 2
2 1 3
2 1 3
1 3 2
2 3 1
...

output:

3

result:

ok 1 number(s): "3"

Test #27:

score: 0
Accepted
time: 3907ms
memory: 5496kb

input:

10000
3 2 1
2 1 3
1 2 3
1 3 2
3 2 1
3 2 1
1 3 2
3 1 2
1 3 2
3 2 1
1 3 2
1 3 2
3 2 1
1 2 3
3 2 1
1 3 2
3 2 1
3 2 1
2 1 3
2 3 1
3 2 1
3 1 2
1 3 2
3 2 1
3 2 1
3 1 2
1 2 3
2 3 1
3 2 1
3 1 2
1 3 2
3 2 1
1 3 2
1 3 2
3 1 2
3 2 1
2 1 3
1 3 2
3 2 1
2 3 1
1 2 3
1 3 2
2 1 3
1 3 2
1 2 3
2 1 3
2 1 3
3 2 1
3 2 1
...

output:

2

result:

ok 1 number(s): "2"

Test #28:

score: 0
Accepted
time: 3895ms
memory: 5660kb

input:

10000
1 3 2
1 3 2
2 3 1
2 3 1
1 3 2
2 1 3
2 1 3
2 1 3
3 1 2
2 1 3
2 3 1
3 2 1
3 2 1
3 1 2
1 3 2
1 3 2
2 1 3
3 2 1
1 3 2
2 1 3
3 1 2
1 2 3
2 1 3
1 3 2
2 1 3
3 1 2
2 3 1
1 2 3
3 2 1
3 2 1
1 3 2
1 2 3
3 2 1
1 2 3
1 3 2
3 1 2
2 1 3
2 1 3
3 2 1
1 2 3
3 2 1
2 3 1
2 3 1
1 3 2
3 1 2
1 3 2
3 2 1
2 3 1
1 3 2
...

output:

3

result:

ok 1 number(s): "3"

Test #29:

score: 0
Accepted
time: 3896ms
memory: 5708kb

input:

10000
2 1 3
3 1 2
3 1 2
1 2 3
1 3 2
3 1 2
2 3 1
2 3 1
1 3 2
1 2 3
3 2 1
3 2 1
1 2 3
2 3 1
2 3 1
3 2 1
3 2 1
3 2 1
3 2 1
3 1 2
3 1 2
2 3 1
3 1 2
3 1 2
1 2 3
3 1 2
3 2 1
3 1 2
1 2 3
1 3 2
1 3 2
2 3 1
1 3 2
2 3 1
2 3 1
2 3 1
1 3 2
2 1 3
1 3 2
3 1 2
3 1 2
1 3 2
1 2 3
1 3 2
1 2 3
3 1 2
3 2 1
3 2 1
3 2 1
...

output:

2

result:

ok 1 number(s): "2"

Test #30:

score: 0
Accepted
time: 3915ms
memory: 5420kb

input:

10000
1 2 3
2 3 1
2 3 1
1 2 3
2 3 1
1 2 3
3 1 2
3 2 1
1 3 2
2 1 3
2 1 3
1 2 3
2 3 1
3 1 2
1 2 3
3 1 2
1 3 2
1 3 2
1 3 2
2 3 1
1 3 2
1 3 2
1 2 3
3 2 1
3 1 2
3 2 1
1 3 2
2 3 1
3 1 2
1 3 2
1 3 2
2 1 3
3 1 2
2 1 3
2 3 1
3 1 2
2 3 1
3 2 1
1 3 2
3 1 2
3 1 2
3 1 2
3 1 2
2 1 3
2 3 1
2 1 3
1 3 2
3 2 1
2 1 3
...

output:

1

result:

ok 1 number(s): "1"

Test #31:

score: 0
Accepted
time: 3890ms
memory: 5420kb

input:

10000
3 1 2
3 2 1
2 3 1
2 1 3
3 2 1
1 2 3
2 3 1
2 3 1
2 1 3
2 1 3
3 1 2
2 1 3
2 1 3
2 3 1
1 3 2
3 1 2
2 1 3
1 2 3
2 1 3
2 1 3
1 2 3
3 1 2
2 1 3
2 1 3
2 3 1
1 2 3
1 3 2
1 3 2
2 3 1
1 3 2
2 3 1
3 1 2
3 2 1
2 3 1
2 1 3
2 3 1
2 1 3
2 1 3
2 1 3
2 1 3
1 3 2
2 3 1
3 2 1
3 1 2
3 2 1
3 1 2
3 2 1
2 3 1
2 1 3
...

output:

2

result:

ok 1 number(s): "2"

Test #32:

score: 0
Accepted
time: 41ms
memory: 3856kb

input:

1000
1 2 3
2 3 1
1 3 2
3 1 2
2 1 3
1 2 3
3 2 1
1 2 3
1 2 3
3 2 1
3 2 1
3 1 2
2 3 1
1 2 3
2 1 3
3 2 1
3 2 1
1 3 2
1 3 2
3 2 1
3 2 1
3 1 2
1 2 3
1 3 2
1 3 2
1 2 3
3 1 2
1 3 2
3 2 1
1 3 2
2 1 3
3 1 2
2 3 1
2 1 3
2 3 1
3 1 2
3 1 2
2 1 3
3 1 2
1 2 3
1 2 3
2 3 1
2 1 3
2 1 3
1 3 2
3 1 2
2 3 1
1 3 2
3 1 2
1...

output:

2

result:

ok 1 number(s): "2"

Test #33:

score: 0
Accepted
time: 40ms
memory: 3768kb

input:

1000
2 3 1
3 2 1
2 1 3
1 3 2
1 2 3
1 3 2
1 3 2
3 2 1
3 2 1
2 3 1
2 3 1
3 2 1
2 1 3
3 2 1
3 1 2
3 2 1
2 1 3
1 3 2
3 1 2
3 1 2
1 3 2
2 1 3
1 2 3
1 3 2
1 2 3
2 1 3
1 3 2
3 1 2
1 2 3
3 2 1
1 3 2
3 1 2
2 1 3
1 2 3
3 2 1
3 2 1
1 2 3
2 3 1
2 3 1
3 2 1
1 3 2
3 2 1
2 3 1
2 3 1
3 1 2
3 2 1
3 1 2
1 2 3
1 3 2
3...

output:

1

result:

ok 1 number(s): "1"

Test #34:

score: 0
Accepted
time: 40ms
memory: 3792kb

input:

1000
2 1 3
2 3 1
3 2 1
2 1 3
2 3 1
1 2 3
3 2 1
3 1 2
2 3 1
2 3 1
3 2 1
1 2 3
1 2 3
2 3 1
1 3 2
2 1 3
1 2 3
3 2 1
3 1 2
1 2 3
2 3 1
2 3 1
1 2 3
3 2 1
3 1 2
1 2 3
1 2 3
1 3 2
3 2 1
3 2 1
3 2 1
1 3 2
3 1 2
2 1 3
1 2 3
2 1 3
2 3 1
1 2 3
2 3 1
2 3 1
3 1 2
2 3 1
2 3 1
3 2 1
3 1 2
2 1 3
3 2 1
1 2 3
1 2 3
1...

output:

2

result:

ok 1 number(s): "2"

Test #35:

score: 0
Accepted
time: 41ms
memory: 3852kb

input:

1000
3 2 1
1 2 3
3 2 1
2 3 1
2 3 1
2 3 1
3 2 1
2 3 1
3 1 2
2 1 3
2 3 1
2 1 3
2 1 3
3 2 1
3 2 1
3 2 1
1 2 3
1 3 2
3 1 2
2 3 1
2 1 3
1 2 3
3 2 1
1 2 3
1 2 3
3 2 1
1 3 2
2 1 3
3 2 1
1 2 3
1 2 3
2 3 1
1 3 2
2 3 1
3 2 1
3 2 1
2 1 3
2 1 3
3 2 1
1 2 3
3 1 2
2 3 1
3 2 1
2 3 1
3 1 2
1 2 3
3 1 2
2 1 3
1 2 3
1...

output:

1

result:

ok 1 number(s): "1"

Test #36:

score: 0
Accepted
time: 41ms
memory: 4068kb

input:

1000
1 3 2
3 2 1
3 2 1
3 1 2
1 2 3
1 3 2
3 2 1
3 1 2
3 1 2
2 3 1
1 3 2
1 3 2
3 2 1
3 1 2
1 2 3
1 3 2
1 2 3
2 3 1
1 3 2
3 2 1
2 1 3
2 1 3
2 1 3
1 3 2
1 3 2
3 1 2
3 1 2
2 1 3
3 1 2
3 1 2
2 1 3
2 3 1
1 2 3
2 3 1
1 3 2
3 1 2
3 2 1
3 1 2
3 1 2
3 2 1
1 2 3
1 2 3
2 3 1
3 1 2
2 3 1
1 2 3
1 2 3
1 3 2
3 1 2
3...

output:

2

result:

ok 1 number(s): "2"

Test #37:

score: 0
Accepted
time: 41ms
memory: 4064kb

input:

1000
1 3 2
3 1 2
2 1 3
3 2 1
2 1 3
1 2 3
3 2 1
1 2 3
3 2 1
3 2 1
1 2 3
3 1 2
3 1 2
2 3 1
1 2 3
1 3 2
3 1 2
3 2 1
1 2 3
3 2 1
2 3 1
3 2 1
2 1 3
1 3 2
1 3 2
3 2 1
1 2 3
3 1 2
1 2 3
2 3 1
2 3 1
1 3 2
3 1 2
2 3 1
2 3 1
1 2 3
3 2 1
2 3 1
2 1 3
1 3 2
3 2 1
3 1 2
1 2 3
1 2 3
3 1 2
3 1 2
1 3 2
3 2 1
3 1 2
2...

output:

3

result:

ok 1 number(s): "3"

Test #38:

score: 0
Accepted
time: 41ms
memory: 4028kb

input:

1000
1 2 3
1 3 2
2 1 3
2 3 1
3 2 1
2 3 1
2 1 3
1 2 3
2 1 3
2 3 1
1 3 2
2 1 3
2 1 3
1 2 3
3 2 1
2 1 3
3 2 1
1 2 3
1 3 2
3 1 2
2 1 3
2 1 3
3 2 1
2 1 3
3 1 2
3 2 1
3 1 2
1 3 2
2 1 3
1 2 3
1 3 2
2 3 1
1 3 2
2 3 1
2 3 1
3 1 2
2 3 1
1 2 3
2 3 1
2 3 1
1 3 2
1 3 2
2 3 1
3 1 2
1 3 2
1 2 3
2 1 3
3 2 1
2 3 1
2...

output:

2

result:

ok 1 number(s): "2"

Test #39:

score: 0
Accepted
time: 41ms
memory: 3772kb

input:

1000
1 2 3
1 3 2
1 2 3
2 1 3
1 2 3
2 3 1
1 3 2
2 3 1
3 2 1
3 1 2
3 1 2
3 2 1
1 2 3
1 3 2
3 2 1
1 3 2
3 1 2
3 1 2
3 2 1
3 1 2
2 3 1
2 1 3
3 2 1
2 1 3
2 1 3
3 2 1
3 1 2
2 3 1
1 3 2
3 1 2
1 2 3
1 2 3
1 3 2
2 1 3
1 3 2
1 2 3
1 3 2
2 1 3
3 2 1
3 2 1
1 3 2
1 2 3
3 2 1
3 2 1
2 1 3
1 3 2
3 1 2
1 3 2
3 1 2
1...

output:

3

result:

ok 1 number(s): "3"

Test #40:

score: 0
Accepted
time: 41ms
memory: 3784kb

input:

1000
1 2 3
2 3 1
1 2 3
1 3 2
1 3 2
2 1 3
1 3 2
2 1 3
2 3 1
1 3 2
3 1 2
2 1 3
1 2 3
3 2 1
1 3 2
1 3 2
3 1 2
3 2 1
2 1 3
3 2 1
1 2 3
2 1 3
3 2 1
1 2 3
2 1 3
1 2 3
3 1 2
2 1 3
1 3 2
1 2 3
2 3 1
3 1 2
2 3 1
3 1 2
1 3 2
2 3 1
3 1 2
2 1 3
1 3 2
2 3 1
2 1 3
1 3 2
3 2 1
2 3 1
1 2 3
2 3 1
1 3 2
1 2 3
3 2 1
3...

output:

3

result:

ok 1 number(s): "3"

Test #41:

score: 0
Accepted
time: 40ms
memory: 3840kb

input:

1000
1 2 3
3 1 2
2 3 1
3 2 1
3 2 1
2 3 1
3 2 1
1 2 3
2 1 3
2 1 3
3 1 2
2 1 3
2 3 1
3 2 1
2 1 3
1 3 2
3 2 1
2 3 1
2 3 1
1 2 3
3 1 2
2 3 1
3 2 1
2 3 1
3 2 1
1 2 3
3 2 1
2 1 3
1 2 3
1 3 2
2 1 3
1 3 2
2 1 3
1 2 3
1 3 2
3 2 1
2 3 1
2 3 1
1 2 3
1 3 2
1 3 2
1 2 3
2 3 1
1 2 3
2 3 1
2 3 1
2 1 3
1 3 2
2 1 3
2...

output:

1

result:

ok 1 number(s): "1"

Test #42:

score: 0
Accepted
time: 41ms
memory: 4024kb

input:

1000
1 3 2
1 3 2
2 3 1
2 3 1
1 3 2
2 1 3
1 2 3
3 2 1
2 1 3
3 1 2
3 1 2
1 3 2
2 1 3
1 3 2
2 3 1
1 3 2
1 3 2
1 2 3
2 3 1
3 2 1
1 2 3
3 1 2
1 2 3
1 3 2
3 2 1
2 1 3
1 2 3
3 2 1
3 1 2
2 1 3
2 3 1
3 1 2
2 3 1
1 3 2
1 3 2
3 2 1
1 2 3
1 3 2
1 2 3
1 2 3
2 1 3
3 1 2
2 1 3
3 2 1
2 1 3
2 3 1
3 2 1
2 1 3
2 3 1
1...

output:

1

result:

ok 1 number(s): "1"

Test #43:

score: 0
Accepted
time: 41ms
memory: 3832kb

input:

1000
3 1 2
1 3 2
1 3 2
1 3 2
3 2 1
1 2 3
1 3 2
1 2 3
3 2 1
1 3 2
3 2 1
2 3 1
2 3 1
3 1 2
3 1 2
2 3 1
3 2 1
1 2 3
3 2 1
1 2 3
3 2 1
1 3 2
3 2 1
3 2 1
3 1 2
2 1 3
2 1 3
2 3 1
3 1 2
2 1 3
3 1 2
1 2 3
1 3 2
1 3 2
2 3 1
3 2 1
3 1 2
2 3 1
3 2 1
3 1 2
2 1 3
1 3 2
1 3 2
2 1 3
3 1 2
3 2 1
3 2 1
1 3 2
1 2 3
1...

output:

3

result:

ok 1 number(s): "3"

Test #44:

score: 0
Accepted
time: 41ms
memory: 3816kb

input:

1000
1 3 2
1 2 3
2 3 1
1 2 3
3 2 1
3 1 2
3 1 2
1 3 2
2 1 3
1 3 2
1 2 3
3 1 2
1 3 2
1 2 3
3 2 1
1 2 3
1 2 3
3 1 2
2 1 3
3 2 1
3 1 2
3 1 2
3 1 2
3 2 1
3 2 1
2 1 3
2 1 3
1 3 2
3 1 2
1 3 2
2 1 3
3 1 2
1 3 2
3 2 1
3 1 2
1 2 3
2 1 3
2 3 1
2 3 1
1 2 3
3 2 1
2 1 3
1 2 3
3 1 2
2 3 1
3 1 2
2 3 1
2 1 3
3 2 1
2...

output:

2

result:

ok 1 number(s): "2"

Test #45:

score: 0
Accepted
time: 41ms
memory: 3996kb

input:

1000
2 3 1
3 2 1
1 3 2
1 2 3
1 3 2
3 1 2
1 2 3
1 3 2
3 1 2
3 2 1
3 2 1
3 2 1
1 2 3
3 1 2
3 1 2
3 1 2
1 3 2
1 2 3
2 3 1
3 2 1
2 1 3
2 1 3
3 2 1
1 3 2
3 1 2
2 1 3
1 3 2
3 1 2
3 2 1
3 2 1
2 3 1
1 3 2
2 1 3
3 1 2
2 3 1
1 2 3
2 3 1
3 1 2
3 2 1
2 1 3
2 1 3
3 1 2
3 2 1
2 1 3
2 1 3
2 1 3
1 3 2
2 1 3
1 2 3
3...

output:

3

result:

ok 1 number(s): "3"

Test #46:

score: 0
Accepted
time: 40ms
memory: 4056kb

input:

1000
2 1 3
3 1 2
2 3 1
2 3 1
3 1 2
2 1 3
1 3 2
2 1 3
1 3 2
2 3 1
2 1 3
1 2 3
3 1 2
2 1 3
3 2 1
2 1 3
3 2 1
1 2 3
2 1 3
1 3 2
1 3 2
3 1 2
3 1 2
1 3 2
2 3 1
2 1 3
3 2 1
3 1 2
1 3 2
2 1 3
2 3 1
1 2 3
2 3 1
1 2 3
2 3 1
1 2 3
1 2 3
2 1 3
1 3 2
1 2 3
3 2 1
3 1 2
1 2 3
2 1 3
1 2 3
3 2 1
2 1 3
1 3 2
1 3 2
3...

output:

2

result:

ok 1 number(s): "2"

Test #47:

score: 0
Accepted
time: 41ms
memory: 4056kb

input:

1000
3 1 2
3 2 1
2 3 1
3 1 2
3 1 2
1 3 2
3 1 2
2 3 1
3 2 1
3 1 2
1 2 3
3 1 2
2 3 1
1 3 2
3 1 2
1 3 2
1 2 3
1 3 2
2 3 1
2 1 3
3 1 2
2 1 3
3 1 2
2 1 3
2 3 1
1 2 3
2 3 1
2 1 3
3 1 2
2 1 3
1 2 3
1 2 3
3 2 1
2 1 3
2 3 1
1 2 3
1 3 2
3 2 1
1 2 3
1 2 3
2 1 3
3 2 1
2 3 1
2 1 3
2 3 1
2 1 3
1 3 2
2 3 1
3 1 2
3...

output:

2

result:

ok 1 number(s): "2"

Test #48:

score: 0
Accepted
time: 37ms
memory: 3784kb

input:

1000
2 3 1
2 3 1
3 2 1
3 1 2
3 2 1
1 3 2
1 3 2
2 3 1
1 3 2
1 2 3
3 1 2
3 2 1
1 2 3
1 3 2
2 1 3
3 2 1
1 2 3
3 1 2
1 2 3
2 3 1
2 3 1
1 3 2
1 3 2
2 3 1
3 2 1
2 3 1
3 1 2
3 2 1
2 1 3
3 1 2
3 1 2
1 2 3
3 1 2
1 2 3
3 1 2
2 1 3
1 2 3
2 1 3
2 1 3
1 2 3
1 3 2
3 1 2
2 1 3
3 1 2
1 3 2
1 3 2
1 3 2
1 3 2
1 2 3
2...

output:

2

result:

ok 1 number(s): "2"

Test #49:

score: 0
Accepted
time: 41ms
memory: 3760kb

input:

1000
3 1 2
1 2 3
2 1 3
1 3 2
3 2 1
1 3 2
2 3 1
3 1 2
3 1 2
2 1 3
1 3 2
3 2 1
2 3 1
3 2 1
2 1 3
2 3 1
3 1 2
2 3 1
1 2 3
3 2 1
1 3 2
3 2 1
3 2 1
3 1 2
1 3 2
3 2 1
1 3 2
2 3 1
2 1 3
3 1 2
2 3 1
2 3 1
2 3 1
2 1 3
3 1 2
2 1 3
2 1 3
3 2 1
2 1 3
3 2 1
1 2 3
3 2 1
2 3 1
3 2 1
2 3 1
3 2 1
3 2 1
3 1 2
3 1 2
3...

output:

1

result:

ok 1 number(s): "1"

Test #50:

score: 0
Accepted
time: 41ms
memory: 3772kb

input:

1000
1 3 2
3 2 1
2 1 3
3 1 2
3 2 1
1 2 3
1 3 2
3 1 2
3 1 2
1 2 3
2 1 3
1 3 2
1 3 2
1 3 2
1 3 2
1 3 2
3 1 2
3 2 1
2 1 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
3 1 2
1 3 2
1 2 3
1 2 3
2 1 3
1 3 2
3 2 1
2 3 1
3 2 1
1 3 2
1 3 2
2 3 1
2 3 1
2 3 1
2 3 1
1 3 2
3 1 2
2 3 1
1 2 3
3 2 1
1 3 2
2 3 1
2 3 1
3 2 1
2 3 1
1...

output:

1

result:

ok 1 number(s): "1"

Test #51:

score: 0
Accepted
time: 42ms
memory: 3796kb

input:

1000
2 3 1
2 1 3
1 2 3
2 3 1
2 3 1
1 3 2
3 2 1
1 3 2
2 1 3
1 2 3
2 1 3
1 3 2
2 1 3
3 2 1
2 3 1
1 3 2
3 1 2
2 3 1
1 2 3
3 2 1
2 3 1
1 3 2
2 3 1
1 2 3
3 2 1
3 1 2
3 1 2
2 1 3
1 3 2
1 2 3
2 3 1
1 2 3
1 3 2
2 1 3
3 1 2
3 2 1
1 3 2
2 3 1
1 2 3
2 1 3
1 3 2
3 1 2
3 2 1
3 1 2
1 3 2
3 1 2
3 2 1
3 1 2
3 1 2
3...

output:

1

result:

ok 1 number(s): "1"

Test #52:

score: 0
Accepted
time: 3892ms
memory: 5428kb

input:

10000
1 3 2
3 2 1
1 2 3
2 3 1
1 2 3
2 3 1
1 2 3
3 1 2
1 2 3
1 3 2
2 1 3
2 1 3
1 3 2
3 1 2
2 3 1
3 1 2
2 1 3
2 1 3
3 1 2
3 1 2
2 1 3
1 2 3
2 1 3
3 1 2
3 1 2
3 2 1
1 3 2
1 3 2
3 2 1
3 2 1
2 3 1
3 1 2
1 3 2
3 2 1
3 1 2
2 3 1
2 3 1
2 3 1
3 1 2
1 3 2
2 1 3
1 3 2
2 3 1
2 3 1
3 1 2
3 1 2
3 2 1
2 3 1
1 2 3
...

output:

1

result:

ok 1 number(s): "1"

Test #53:

score: 0
Accepted
time: 3881ms
memory: 5496kb

input:

10000
1 2 3
1 2 3
2 1 3
1 3 2
2 3 1
2 1 3
1 2 3
3 2 1
3 2 1
2 1 3
3 2 1
2 3 1
3 2 1
2 1 3
1 2 3
3 1 2
2 1 3
1 2 3
1 3 2
3 2 1
1 3 2
2 3 1
3 2 1
2 1 3
3 1 2
2 1 3
3 2 1
3 2 1
1 3 2
1 3 2
1 3 2
3 2 1
1 3 2
3 1 2
2 3 1
1 2 3
1 3 2
2 3 1
1 2 3
1 2 3
2 1 3
2 3 1
1 3 2
2 1 3
2 3 1
1 2 3
3 2 1
3 2 1
3 1 2
...

output:

2

result:

ok 1 number(s): "2"

Test #54:

score: 0
Accepted
time: 3939ms
memory: 5496kb

input:

10000
3 2 1
2 1 3
1 3 2
2 3 1
2 3 1
1 2 3
1 2 3
3 1 2
1 2 3
1 3 2
1 2 3
1 3 2
3 2 1
2 3 1
3 2 1
3 2 1
3 2 1
1 3 2
3 1 2
2 3 1
1 3 2
2 1 3
3 1 2
2 1 3
1 2 3
2 3 1
3 2 1
3 1 2
3 1 2
3 1 2
3 2 1
2 3 1
3 2 1
3 1 2
3 2 1
2 1 3
1 3 2
2 1 3
3 2 1
1 3 2
2 3 1
3 1 2
2 1 3
3 1 2
2 3 1
2 1 3
3 1 2
2 3 1
2 1 3
...

output:

1

result:

ok 1 number(s): "1"

Test #55:

score: 0
Accepted
time: 3918ms
memory: 5472kb

input:

10000
1 3 2
2 1 3
2 1 3
3 2 1
1 3 2
2 3 1
2 1 3
2 1 3
1 2 3
3 2 1
2 3 1
1 3 2
1 3 2
1 3 2
2 1 3
3 2 1
1 2 3
2 3 1
2 1 3
3 2 1
1 3 2
1 2 3
1 2 3
1 3 2
3 1 2
3 2 1
2 1 3
3 1 2
3 2 1
1 2 3
2 3 1
3 2 1
1 2 3
2 1 3
3 1 2
3 1 2
1 3 2
3 1 2
3 1 2
1 3 2
3 2 1
3 2 1
3 1 2
2 1 3
2 3 1
1 3 2
3 1 2
1 2 3
1 3 2
...

output:

3

result:

ok 1 number(s): "3"

Test #56:

score: 0
Accepted
time: 3883ms
memory: 5636kb

input:

10000
3 1 2
2 1 3
2 3 1
1 3 2
2 3 1
1 2 3
3 1 2
1 3 2
2 3 1
2 3 1
1 2 3
2 3 1
1 2 3
3 2 1
1 2 3
1 3 2
2 1 3
1 2 3
2 3 1
2 3 1
1 2 3
2 3 1
1 2 3
1 3 2
1 2 3
3 2 1
3 1 2
1 3 2
3 2 1
3 1 2
2 1 3
2 3 1
2 3 1
1 2 3
1 3 2
2 1 3
1 3 2
3 1 2
1 3 2
2 3 1
1 2 3
1 2 3
3 2 1
1 2 3
3 1 2
1 2 3
3 2 1
3 1 2
3 1 2
...

output:

2

result:

ok 1 number(s): "2"

Test #57:

score: 0
Accepted
time: 3908ms
memory: 5416kb

input:

10000
3 1 2
2 3 1
2 3 1
1 3 2
2 3 1
2 3 1
2 1 3
3 1 2
3 1 2
2 3 1
2 3 1
3 1 2
2 3 1
1 2 3
1 3 2
1 2 3
1 2 3
3 2 1
1 3 2
3 2 1
1 2 3
1 2 3
1 2 3
1 2 3
3 1 2
2 3 1
1 3 2
1 2 3
1 2 3
2 3 1
1 3 2
1 2 3
3 1 2
3 1 2
1 3 2
2 1 3
3 2 1
3 2 1
1 2 3
3 1 2
2 1 3
1 3 2
1 2 3
2 1 3
2 1 3
2 1 3
1 3 2
3 2 1
1 2 3
...

output:

1

result:

ok 1 number(s): "1"

Test #58:

score: 0
Accepted
time: 3920ms
memory: 5708kb

input:

10000
3 2 1
2 1 3
1 3 2
3 1 2
1 3 2
3 1 2
1 3 2
1 2 3
3 1 2
2 3 1
3 2 1
2 3 1
1 2 3
1 3 2
2 1 3
2 3 1
3 2 1
2 1 3
1 2 3
2 1 3
1 3 2
3 1 2
1 3 2
1 2 3
2 3 1
3 1 2
2 3 1
1 2 3
1 3 2
3 2 1
1 3 2
1 3 2
2 3 1
3 1 2
1 2 3
3 1 2
3 2 1
2 3 1
3 1 2
2 1 3
3 2 1
2 3 1
3 1 2
2 1 3
2 1 3
1 3 2
3 2 1
2 1 3
3 1 2
...

output:

1

result:

ok 1 number(s): "1"

Test #59:

score: 0
Accepted
time: 3897ms
memory: 5400kb

input:

10000
2 1 3
2 3 1
1 3 2
2 3 1
2 3 1
2 3 1
3 2 1
3 1 2
1 3 2
3 2 1
3 1 2
1 3 2
3 2 1
1 3 2
1 2 3
2 3 1
1 3 2
2 1 3
2 1 3
1 3 2
3 1 2
3 1 2
2 1 3
1 2 3
3 2 1
1 2 3
2 1 3
3 1 2
1 3 2
2 1 3
3 1 2
1 3 2
3 1 2
1 3 2
2 3 1
2 1 3
2 1 3
1 2 3
3 2 1
2 1 3
2 1 3
1 2 3
3 2 1
1 2 3
3 2 1
1 3 2
1 2 3
3 1 2
1 3 2
...

output:

2

result:

ok 1 number(s): "2"

Test #60:

score: 0
Accepted
time: 3892ms
memory: 5508kb

input:

10000
2 1 3
1 2 3
1 3 2
2 1 3
2 1 3
1 2 3
3 2 1
2 1 3
2 3 1
2 3 1
2 1 3
1 2 3
2 3 1
2 1 3
3 1 2
1 2 3
2 1 3
2 3 1
1 3 2
1 2 3
2 3 1
3 1 2
1 2 3
2 1 3
1 3 2
3 2 1
3 1 2
1 2 3
2 1 3
2 3 1
2 3 1
3 2 1
2 3 1
1 3 2
2 3 1
3 1 2
2 1 3
1 2 3
3 1 2
3 2 1
3 1 2
1 3 2
2 1 3
3 1 2
1 3 2
3 1 2
3 1 2
2 1 3
2 3 1
...

output:

3

result:

ok 1 number(s): "3"

Test #61:

score: 0
Accepted
time: 3912ms
memory: 5416kb

input:

10000
1 2 3
1 3 2
2 1 3
1 3 2
1 3 2
2 3 1
1 2 3
1 3 2
1 3 2
2 3 1
1 3 2
2 3 1
3 1 2
3 2 1
1 3 2
3 1 2
2 1 3
2 3 1
2 3 1
3 2 1
3 2 1
2 3 1
3 1 2
1 2 3
1 3 2
2 3 1
3 2 1
1 3 2
3 2 1
1 2 3
2 1 3
2 3 1
1 3 2
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
2 1 3
1 2 3
2 1 3
2 3 1
2 1 3
1 2 3
2 3 1
3 2 1
2 3 1
2 1 3
3 2 1
...

output:

1

result:

ok 1 number(s): "1"

Test #62:

score: -100
Time Limit Exceeded

input:

10000
1 2 3
3 1 2
3 1 2
2 1 3
1 3 2
2 1 3
2 1 3
3 1 2
1 2 3
3 2 1
2 1 3
2 1 3
1 2 3
1 3 2
1 3 2
1 3 2
1 3 2
1 3 2
1 2 3
1 3 2
2 3 1
3 2 1
2 3 1
2 3 1
2 1 3
1 2 3
2 3 1
1 3 2
1 3 2
1 3 2
1 2 3
2 1 3
3 2 1
1 3 2
2 1 3
3 1 2
3 1 2
3 1 2
2 3 1
2 3 1
3 2 1
1 3 2
1 2 3
2 3 1
2 1 3
3 2 1
1 3 2
3 2 1
3 2 1
...

output:

2

result: