QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#127745#6325. Peaceful ResultsEnergy_is_not_overAC ✓246ms38852kbC++177.5kb2023-07-19 23:34:422023-07-19 23:34:43

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-19 23:34:43]
  • 评测
  • 测评结果:AC
  • 用时:246ms
  • 内存:38852kb
  • [2023-07-19 23:34:42]
  • 提交

answer

/**
 *  created: 17/07/2023, 20:21:09
**/

#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

const int max_n = 1500111, mod = 998244353;

template<int mod>
struct NTT {
    static constexpr int max_lev = __builtin_ctz(mod - 1);

    int prod[2][max_lev - 1];

    NTT() {
        int root = (mod == 998244353) ? 31 : find_root();
        int rroot = inv(root);
        vector<vector<int>> roots(2, vector<int>(max_lev - 1));
        roots[0][max_lev - 2] = root;
        roots[1][max_lev - 2] = rroot;
        for (int tp = 0; tp < 2; ++tp) {
            for (int i = max_lev - 3; i >= 0; --i) {
                roots[tp][i] = mul(roots[tp][i + 1], roots[tp][i + 1]);
            }
        }
        for (int tp = 0; tp < 2; ++tp) {
            int cur = 1;
            for (int i = 0; i < max_lev - 1; ++i) {
                prod[tp][i] = mul(cur, roots[tp][i]);
                cur = mul(cur, roots[tp ^ 1][i]);
            }
        }
    }

    template<bool inverse>
    void fft(int *a, int lg) const {
        const int n = 1 << lg;
        int pos = max_lev - 1;
        for (int it = 0; it < lg; ++it) {
            const int h = inverse ? lg - 1 - it : it;
            const int shift = (1 << (lg - h - 1));
            int coef = 1;
            for (int start = 0; start < (1 << h); ++start) {
                for (int i = start << (lg - h); i < (start << (lg - h)) + shift; ++i) {
                    if (!inverse) {
                        const int y = mul(a[i + shift], coef);
                        a[i + shift] = a[i];
                        inc(a[i], y);
                        dec(a[i + shift], y);
                    } else {
                        const int y = mul(a[i] + mod - a[i + shift], coef);
                        inc(a[i], a[i + shift]);
                        a[i + shift] = y;
                    }
                }
                coef = mul(coef, prod[inverse][__builtin_ctz(~start)]);
            }
        }
        if (inverse) {
            const int rn = inv(n);
            for (int i = 0; i < n; ++i) {
                a[i] = mul(a[i], rn);
            }
        }
    }

    vector<int> product(vector<int> a, vector<int> b) const {
        if (a.empty() || b.empty()) {
            return {};
        }
        const int sz = a.size() + b.size() - 1;
        const int lg = 32 - __builtin_clz(sz - 1), n = 1 << lg;
        a.resize(n);
        b.resize(n);
        fft<false>(a.data(), lg);
        fft<false>(b.data(), lg);
        for (int i = 0; i < n; ++i) {
            a[i] = mul(a[i], b[i]);
        }
        fft<true>(a.data(), lg);
        a.resize(sz);
        return a;
    }

    vector<int> square(vector<int> a) const {
        if (a.empty()) {
            return {};
        }
        const int sz = a.size() + a.size() - 1;
        const int lg = 32 - __builtin_clz(sz - 1), n = 1 << lg;
        a.resize(n);
        fft<false>(a.data(), lg);
        for (int i = 0; i < n; ++i) {
            a[i] = mul(a[i], a[i]);
        }
        fft<true>(a.data(), lg);
        a.resize(sz);
        return a;
    }

    static int find_root() {
        for (int root = 2; ; ++root) {
            if (power(root, (1 << max_lev)) == 1 && power(root, (1 << (max_lev - 1))) != 1) {
                return root;
            }
        }
    }

    static inline void inc(int &x, int y) {
        x += y;
        if (x >= mod) {
            x -= mod;
        }
    }

    static inline void dec(int &x, int y) {
        x -= y;
        if (x < 0) {
            x += mod;
        }
    }

    static inline int mul(int x, int y) {
        return (1LL * x * y) % mod;
    }

    static int power(int x, int y) {
        if (y == 0) {
            return 1;
        }
        if (y % 2 == 0) {
            return power(mul(x, x), y / 2);
        }
        return mul(x, power(x, y - 1));
    }

    static int inv(int x) {
        return power(x, mod - 2);
    }
};

NTT<mod> ntt;

inline void inc(int &x, int y) {
    x += y;
    if (x >= mod) {
        x -= mod;
    }
}

inline void dec(int &x, int y) {
    x -= y;
    if (x < 0) {
        x += mod;
    }
}

inline int neg(int x) {
    return x ? (mod - x) : 0;
}

inline int mul(int x) {
    return x;
}

template<typename... Args>
inline int mul(int x, Args... args) {
    return (1LL * x * mul(args...)) % mod;
}

int power(int a, long long b) {
    int res = 1 % mod;
    while (b) {
        if (b % 2) {
            res = mul(res, a);
        }
        b /= 2;
        a = mul(a, a);
    }
    return res;
}

int inv(int x) {
    return power(x, mod - 2);
}

const int max_f = max_n;
const int max_rf = max_f;
static_assert(max_f >= 1 && max_rf >= 1);

int F[max_f], rf[max_rf];

bool frf_calculated = []() {
    F[0] = 1;
    for (int i = 1; i < max_f; ++i) {
        F[i] = mul(i, F[i - 1]);
    }
    int x = F[min(max_f, max_rf) - 1];
    for (int i = max_f; i < max_rf; ++i) {
        x = mul(x, i);
    }
    rf[max_rf - 1] = inv(x);
    for (int i = max_rf - 2; i >= 0; --i) {
        rf[i] = mul(i + 1, rf[i + 1]);
    }
    return true;
}();

int get_c(int n, int k) {
    if (n < k || k < 0) {
        return 0;
    }
    assert(n < max_f && k < max_rf && n - k < max_rf);
    return mul(F[n], rf[k], rf[n - k]);
}

int get_c(int n, int k1, int k2) {
    if (n < k1 + k2 || k1 < 0 || k2 < 0) {
        return 0;
    }
    return mul(F[n], rf[k1], rf[k2], rf[n - k1 - k2]);
}

string str_fraction(int x, int n = 20) {
    stringstream res;
    pair<int, int> best(x, 1);
    for (int j = 1; j < n; ++j) {
        best = min(best, {mul(x, j), j});
        best = min(best, {mod - mul(x, j), -j});
    }
    if (best.second < 0) {
        best.first *= -1;
        best.second *= -1;
    }
    res << best.first << "/" << best.second;
    return res.str();
}

int n;
int a, b, c;
int d, e, f;
int g, h, i;

int solve() {
    int res = 0;
    const int k = g - b - e;
    const int l = a + d - h;
    const int m = i - f + a + b;
    if ((m + l) % 3) {
        return 0;
    }
    const int p = (m + l) / 3;
    const int q = p - l;
    vector<int> A(a + 1), B(a + 1);
    for (int y = 0; y <= a; ++y) {
        if (b - p - q + y < 0 || d - p + y < 0) {
            continue;
        }
        A[y] = mul(rf[y], rf[b - p - q + y], rf[d - p + y]);
    }
    for (int y = 0; y <= a; ++y) {
        if (p - a + y < 0 || p - a + y > b || e - q - a + y < 0 || e - q - a + y > c) {
            continue;
        }
        B[y] = mul(rf[y], rf[p - a + y], rf[e - q - a + y]);
    }
    vector<int> C = ntt.product(A, B);
    for (int x = 0; x <= a; ++x) {
        if (q + x < 0 || q + x > b || c - d + p - e + q + x < 0 || c - d + p - e + q + x > c) {
            continue;
        }
        int coef = mul(F[a], F[b], F[c], rf[x], rf[q + x], rf[c - d + p - e + q + x]);
        inc(res, mul(coef, C[a - x]));
    }
    res = mul(res, get_c(n, a, b));
    return res;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    cin >> a >> b >> c;
    cin >> d >> e >> f;
    cin >> g >> h >> i;
    cout << solve() << "\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 15ms
memory: 15280kb

input:

2
2 0 0
1 1 0
1 0 1

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 11ms
memory: 15176kb

input:

3
0 1 2
3 0 0
1 1 1

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 36ms
memory: 18128kb

input:

333333
111111 111111 111111
111111 111111 111111
111111 111111 111111

output:

383902959

result:

ok 1 number(s): "383902959"

Test #4:

score: 0
Accepted
time: 121ms
memory: 28864kb

input:

1500000
500000 500000 500000
500000 500000 500000
500000 500000 500000

output:

355543262

result:

ok 1 number(s): "355543262"

Test #5:

score: 0
Accepted
time: 115ms
memory: 28792kb

input:

1499999
499999 499999 500001
499999 499999 500001
499999 499999 500001

output:

934301164

result:

ok 1 number(s): "934301164"

Test #6:

score: 0
Accepted
time: 16ms
memory: 15180kb

input:

1500000
1 0 1499999
1499999 1 0
0 1499999 1

output:

1500000

result:

ok 1 number(s): "1500000"

Test #7:

score: 0
Accepted
time: 10ms
memory: 15256kb

input:

1499999
0 749999 750000
750000 0 749999
749999 750000 0

output:

713966599

result:

ok 1 number(s): "713966599"

Test #8:

score: 0
Accepted
time: 16ms
memory: 15244kb

input:

1
1 0 0
0 0 1
0 1 0

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: 0
Accepted
time: 7ms
memory: 15184kb

input:

1
0 1 0
0 1 0
0 1 0

output:

1

result:

ok 1 number(s): "1"

Test #10:

score: 0
Accepted
time: 16ms
memory: 15176kb

input:

1
0 0 1
1 0 0
1 0 0

output:

0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 130ms
memory: 28844kb

input:

1499999
500000 500000 499999
499999 499999 500001
499999 499999 500001

output:

617065435

result:

ok 1 number(s): "617065435"

Test #12:

score: 0
Accepted
time: 16ms
memory: 15256kb

input:

2
1 1 0
0 0 2
0 0 2

output:

0

result:

ok 1 number(s): "0"

Test #13:

score: 0
Accepted
time: 118ms
memory: 28792kb

input:

1500000
500000 500001 499999
499999 500000 500001
499999 500000 500001

output:

925862004

result:

ok 1 number(s): "925862004"

Test #14:

score: 0
Accepted
time: 61ms
memory: 21300kb

input:

629197
210878 201408 216911
145293 266423 217481
194751 220179 214267

output:

447295633

result:

ok 1 number(s): "447295633"

Test #15:

score: 0
Accepted
time: 64ms
memory: 21256kb

input:

579097
200209 204257 174631
149110 148890 281097
138034 263752 177311

output:

71830925

result:

ok 1 number(s): "71830925"

Test #16:

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

input:

354224
100316 63899 190009
69306 123829 161089
140523 76088 137613

output:

44852283

result:

ok 1 number(s): "44852283"

Test #17:

score: 0
Accepted
time: 117ms
memory: 27472kb

input:

1229851
383009 323934 522908
551226 311238 367387
547622 353128 329101

output:

39721313

result:

ok 1 number(s): "39721313"

Test #18:

score: 0
Accepted
time: 62ms
memory: 21176kb

input:

858452
195309 312080 351063
384805 51797 421850
200466 301164 356822

output:

506491992

result:

ok 1 number(s): "506491992"

Test #19:

score: 0
Accepted
time: 246ms
memory: 38852kb

input:

1424218
661653 323895 438670
467846 488045 468327
369769 343207 711242

output:

782021141

result:

ok 1 number(s): "782021141"

Test #20:

score: 0
Accepted
time: 117ms
memory: 26880kb

input:

1079733
333391 427895 318447
579853 153924 345956
406031 300755 372947

output:

111229812

result:

ok 1 number(s): "111229812"

Test #21:

score: 0
Accepted
time: 64ms
memory: 20796kb

input:

572270
168517 197624 206129
238722 154914 178634
192692 145891 233687

output:

93444378

result:

ok 1 number(s): "93444378"

Test #22:

score: 0
Accepted
time: 38ms
memory: 17864kb

input:

470911
95201 196020 179690
143795 173744 153372
142604 154489 173818

output:

629148200

result:

ok 1 number(s): "629148200"

Test #23:

score: 0
Accepted
time: 63ms
memory: 20516kb

input:

514907
142312 117185 255410
52426 249434 213047
180346 59381 275180

output:

497502651

result:

ok 1 number(s): "497502651"

Test #24:

score: 0
Accepted
time: 58ms
memory: 20608kb

input:

406588
151239 177967 77382
93189 144948 168451
94378 135309 176901

output:

790871601

result:

ok 1 number(s): "790871601"

Test #25:

score: 0
Accepted
time: 24ms
memory: 16480kb

input:

175290
55982 60345 58963
48359 77923 49008
23679 74616 76995

output:

123245869

result:

ok 1 number(s): "123245869"

Test #26:

score: 0
Accepted
time: 118ms
memory: 28920kb

input:

1387914
512757 474809 400348
378268 216654 792992
649332 374567 364015

output:

676034326

result:

ok 1 number(s): "676034326"

Test #27:

score: 0
Accepted
time: 65ms
memory: 21428kb

input:

764222
219470 230830 313922
331893 97293 335036
97220 292440 374562

output:

158682546

result:

ok 1 number(s): "158682546"

Test #28:

score: 0
Accepted
time: 61ms
memory: 21704kb

input:

753135
242199 294626 216310
175239 287120 290776
282985 150249 319901

output:

971077263

result:

ok 1 number(s): "971077263"

Test #29:

score: 0
Accepted
time: 70ms
memory: 21840kb

input:

907648
254368 314623 338657
266634 210330 430684
203259 377229 327160

output:

657924076

result:

ok 1 number(s): "657924076"

Test #30:

score: 0
Accepted
time: 116ms
memory: 26308kb

input:

734407
287960 273092 173355
91803 383817 258787
317856 268839 147712

output:

302163640

result:

ok 1 number(s): "302163640"

Test #31:

score: 0
Accepted
time: 110ms
memory: 26392kb

input:

802408
296016 284435 221957
207041 242882 352485
117792 274366 410250

output:

54247530

result:

ok 1 number(s): "54247530"

Test #32:

score: 0
Accepted
time: 68ms
memory: 20700kb

input:

562487
158889 225035 178563
148413 302399 111675
148133 215119 199235

output:

169658542

result:

ok 1 number(s): "169658542"

Test #33:

score: 0
Accepted
time: 123ms
memory: 27544kb

input:

999120
389537 311486 298097
316708 332443 349969
261915 402318 334887

output:

352258886

result:

ok 1 number(s): "352258886"

Test #34:

score: 0
Accepted
time: 120ms
memory: 27960kb

input:

1409159
427245 484076 497838
435890 528804 444465
588832 314386 505941

output:

887383005

result:

ok 1 number(s): "887383005"

Test #35:

score: 0
Accepted
time: 118ms
memory: 26964kb

input:

1003619
340241 274051 389327
166457 383901 453261
211841 434615 357163

output:

353962733

result:

ok 1 number(s): "353962733"

Test #36:

score: 0
Accepted
time: 14ms
memory: 15432kb

input:

22574
9246 5094 8234
9209 7482 5883
12089 6331 4154

output:

60839910

result:

ok 1 number(s): "60839910"

Test #37:

score: 0
Accepted
time: 123ms
memory: 28532kb

input:

1415532
478588 564750 372194
512789 526677 376066
217017 566262 632253

output:

625939628

result:

ok 1 number(s): "625939628"

Test #38:

score: 0
Accepted
time: 65ms
memory: 21708kb

input:

662723
241713 270544 150466
205318 236372 221033
329239 165257 168227

output:

186211005

result:

ok 1 number(s): "186211005"

Test #39:

score: 0
Accepted
time: 242ms
memory: 37952kb

input:

1096822
586933 218335 291554
392825 346250 357747
326051 392267 378504

output:

128569855

result:

ok 1 number(s): "128569855"

Test #40:

score: 0
Accepted
time: 121ms
memory: 26196kb

input:

1246485
277064 449274 520147
467862 333900 444723
590215 427647 228623

output:

695555486

result:

ok 1 number(s): "695555486"

Test #41:

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

input:

351715
120661 101781 129273
142995 80157 128563
169330 148880 33505

output:

466480620

result:

ok 1 number(s): "466480620"

Test #42:

score: 0
Accepted
time: 117ms
memory: 27468kb

input:

905498
381722 200474 323302
202271 344030 359197
350698 364396 190404

output:

346377686

result:

ok 1 number(s): "346377686"

Test #43:

score: 0
Accepted
time: 63ms
memory: 21900kb

input:

1064626
261709 325862 477055
516569 367130 180927
307746 452237 304643

output:

557495758

result:

ok 1 number(s): "557495758"

Test #44:

score: 0
Accepted
time: 10ms
memory: 15180kb

input:

494104
224009 132488 137607
15527 180865 297712
203418 197294 93392

output:

0

result:

ok 1 number(s): "0"

Test #45:

score: 0
Accepted
time: 16ms
memory: 15256kb

input:

1153008
315731 708637 128640
128519 347757 676732
267014 535519 350475

output:

0

result:

ok 1 number(s): "0"

Test #46:

score: 0
Accepted
time: 245ms
memory: 37544kb

input:

1470490
550743 481409 438338
763576 96662 610252
363836 262517 844137

output:

964914867

result:

ok 1 number(s): "964914867"

Test #47:

score: 0
Accepted
time: 28ms
memory: 17612kb

input:

476270
72377 235854 168039
1528 311122 163620
254184 15707 206379

output:

0

result:

ok 1 number(s): "0"

Test #48:

score: 0
Accepted
time: 8ms
memory: 15228kb

input:

787189
201940 129464 455785
243491 290356 253342
257543 326980 202666

output:

0

result:

ok 1 number(s): "0"

Test #49:

score: 0
Accepted
time: 8ms
memory: 15184kb

input:

1311581
662049 427399 222133
182392 768551 360638
257311 534768 519502

output:

0

result:

ok 1 number(s): "0"

Test #50:

score: 0
Accepted
time: 29ms
memory: 18056kb

input:

215077
105142 95920 14015
37417 106030 71630
97785 86292 31000

output:

0

result:

ok 1 number(s): "0"

Test #51:

score: 0
Accepted
time: 16ms
memory: 15168kb

input:

680614
190222 59142 431250
229277 326583 124754
244226 267501 168887

output:

0

result:

ok 1 number(s): "0"

Test #52:

score: 0
Accepted
time: 16ms
memory: 15180kb

input:

599441
163256 359629 76556
269072 153998 176371
296850 273987 28604

output:

0

result:

ok 1 number(s): "0"

Test #53:

score: 0
Accepted
time: 15ms
memory: 15176kb

input:

1186565
664884 314828 206853
50093 597130 539342
352770 117639 716156

output:

0

result:

ok 1 number(s): "0"

Test #54:

score: 0
Accepted
time: 16ms
memory: 15176kb

input:

399589
160429 157151 82009
52807 151045 195737
168413 46646 184530

output:

0

result:

ok 1 number(s): "0"

Test #55:

score: 0
Accepted
time: 116ms
memory: 26264kb

input:

498263
277597 129082 91584
146928 169294 182041
198001 220974 79288

output:

20392590

result:

ok 1 number(s): "20392590"

Test #56:

score: 0
Accepted
time: 239ms
memory: 38112kb

input:

1287548
598441 439788 249319
532780 427274 327494
984985 96121 206442

output:

157485795

result:

ok 1 number(s): "157485795"

Test #57:

score: 0
Accepted
time: 12ms
memory: 15228kb

input:

1435275
447804 724373 263098
383152 619901 432222
383304 68399 983572

output:

0

result:

ok 1 number(s): "0"

Test #58:

score: 0
Accepted
time: 12ms
memory: 15296kb

input:

699090
240262 213752 245076
255039 260728 183323
234619 115480 348991

output:

0

result:

ok 1 number(s): "0"

Test #59:

score: 0
Accepted
time: 12ms
memory: 15216kb

input:

972438
478545 285919 207974
128489 319801 524148
286253 298521 387664

output:

0

result:

ok 1 number(s): "0"

Test #60:

score: 0
Accepted
time: 12ms
memory: 15260kb

input:

331352
121624 30247 179481
80755 93304 157293
62835 160621 107896

output:

0

result:

ok 1 number(s): "0"

Test #61:

score: 0
Accepted
time: 16ms
memory: 15284kb

input:

425318
161870 195187 68261
58421 111518 255379
98211 149256 177851

output:

0

result:

ok 1 number(s): "0"

Test #62:

score: 0
Accepted
time: 8ms
memory: 15148kb

input:

592741
319914 259579 13248
148647 194672 249422
378967 175386 38388

output:

0

result:

ok 1 number(s): "0"

Test #63:

score: 0
Accepted
time: 18ms
memory: 16192kb

input:

602228
34962 454429 112837
247881 315495 38852
384357 69191 148680

output:

0

result:

ok 1 number(s): "0"

Test #64:

score: 0
Accepted
time: 15ms
memory: 15232kb

input:

610389
373522 193737 43130
62839 130072 417478
138346 203349 268694

output:

0

result:

ok 1 number(s): "0"

Test #65:

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

input:

161360
82645 44242 34473
66788 59603 34969
48139 22450 90771

output:

559061811

result:

ok 1 number(s): "559061811"

Test #66:

score: 0
Accepted
time: 11ms
memory: 15256kb

input:

591506
92336 192103 307067
13873 290990 286643
28921 254667 307918

output:

0

result:

ok 1 number(s): "0"

Test #67:

score: 0
Accepted
time: 114ms
memory: 28656kb

input:

940718
486143 39848 414727
438813 358245 143660
200948 304832 434938

output:

189368763

result:

ok 1 number(s): "189368763"

Test #68:

score: 0
Accepted
time: 12ms
memory: 15224kb

input:

585970
36092 336501 213377
217719 134212 234039
454324 31689 99957

output:

0

result:

ok 1 number(s): "0"

Test #69:

score: 0
Accepted
time: 11ms
memory: 15212kb

input:

814985
350619 424060 40306
318150 477415 19420
296376 381374 137235

output:

0

result:

ok 1 number(s): "0"

Test #70:

score: 0
Accepted
time: 172ms
memory: 38556kb

input:

1212624
635151 355933 221540
382996 340761 488867
28683 189420 994521

output:

0

result:

ok 1 number(s): "0"

Test #71:

score: 0
Accepted
time: 16ms
memory: 15180kb

input:

825460
28354 541876 255230
334422 299199 191839
166016 391674 267770

output:

0

result:

ok 1 number(s): "0"

Test #72:

score: 0
Accepted
time: 4ms
memory: 15224kb

input:

644697
305286 296842 42569
165080 234255 245362
127688 459557 57452

output:

0

result:

ok 1 number(s): "0"

Test #73:

score: 0
Accepted
time: 16ms
memory: 15248kb

input:

604964
3223 299494 302247
292154 126107 186703
77013 270881 257070

output:

0

result:

ok 1 number(s): "0"

Test #74:

score: 0
Accepted
time: 16ms
memory: 15180kb

input:

3
0 1 2
1 1 1
1 1 1

output:

0

result:

ok 1 number(s): "0"

Test #75:

score: 0
Accepted
time: 12ms
memory: 15212kb

input:

4
2 0 2
2 1 1
2 2 0

output:

24

result:

ok 1 number(s): "24"

Test #76:

score: 0
Accepted
time: 16ms
memory: 15232kb

input:

2
1 1 0
1 0 1
0 2 0

output:

0

result:

ok 1 number(s): "0"

Test #77:

score: 0
Accepted
time: 15ms
memory: 15260kb

input:

3
2 1 0
0 1 2
1 2 0

output:

0

result:

ok 1 number(s): "0"

Test #78:

score: 0
Accepted
time: 15ms
memory: 15260kb

input:

3
0 1 2
1 0 2
0 1 2

output:

0

result:

ok 1 number(s): "0"

Test #79:

score: 0
Accepted
time: 11ms
memory: 15180kb

input:

2
0 2 0
1 0 1
0 1 1

output:

0

result:

ok 1 number(s): "0"

Test #80:

score: 0
Accepted
time: 16ms
memory: 15188kb

input:

4
1 2 1
0 2 2
0 2 2

output:

0

result:

ok 1 number(s): "0"

Test #81:

score: 0
Accepted
time: 16ms
memory: 15216kb

input:

1
0 0 1
0 0 1
0 1 0

output:

0

result:

ok 1 number(s): "0"

Test #82:

score: 0
Accepted
time: 12ms
memory: 15180kb

input:

3
1 0 2
1 2 0
2 1 0

output:

0

result:

ok 1 number(s): "0"

Test #83:

score: 0
Accepted
time: 16ms
memory: 15164kb

input:

3
0 1 2
2 0 1
0 1 2

output:

6

result:

ok 1 number(s): "6"

Test #84:

score: 0
Accepted
time: 15ms
memory: 15220kb

input:

3
1 1 1
2 0 1
0 1 2

output:

0

result:

ok 1 number(s): "0"

Test #85:

score: 0
Accepted
time: 12ms
memory: 15172kb

input:

4
1 1 2
1 1 2
2 1 1

output:

0

result:

ok 1 number(s): "0"

Test #86:

score: 0
Accepted
time: 15ms
memory: 15292kb

input:

2
0 2 0
1 0 1
2 0 0

output:

0

result:

ok 1 number(s): "0"

Test #87:

score: 0
Accepted
time: 12ms
memory: 15232kb

input:

2
0 0 2
1 0 1
0 0 2

output:

0

result:

ok 1 number(s): "0"

Test #88:

score: 0
Accepted
time: 12ms
memory: 15172kb

input:

2
0 1 1
0 2 0
2 0 0

output:

0

result:

ok 1 number(s): "0"

Test #89:

score: 0
Accepted
time: 16ms
memory: 15252kb

input:

3
2 0 1
1 1 1
1 1 1

output:

0

result:

ok 1 number(s): "0"

Test #90:

score: 0
Accepted
time: 16ms
memory: 15164kb

input:

5
1 2 2
1 2 2
1 2 2

output:

270

result:

ok 1 number(s): "270"

Test #91:

score: 0
Accepted
time: 12ms
memory: 15248kb

input:

3
2 1 0
1 0 2
0 1 2

output:

0

result:

ok 1 number(s): "0"

Test #92:

score: 0
Accepted
time: 15ms
memory: 15224kb

input:

3
2 1 0
1 0 2
1 1 1

output:

0

result:

ok 1 number(s): "0"

Test #93:

score: 0
Accepted
time: 10ms
memory: 15216kb

input:

4
2 1 1
1 2 1
0 2 2

output:

0

result:

ok 1 number(s): "0"

Test #94:

score: 0
Accepted
time: 10ms
memory: 15296kb

input:

2
0 1 1
2 0 0
0 0 2

output:

0

result:

ok 1 number(s): "0"

Test #95:

score: 0
Accepted
time: 10ms
memory: 15260kb

input:

2
2 0 0
1 1 0
2 0 0

output:

0

result:

ok 1 number(s): "0"

Test #96:

score: 0
Accepted
time: 15ms
memory: 15176kb

input:

4
2 1 1
1 2 1
1 2 1

output:

0

result:

ok 1 number(s): "0"

Test #97:

score: 0
Accepted
time: 3ms
memory: 15256kb

input:

3
2 1 0
1 1 1
1 2 0

output:

6

result:

ok 1 number(s): "6"

Test #98:

score: 0
Accepted
time: 15ms
memory: 15216kb

input:

2
0 2 0
1 0 1
0 0 2

output:

0

result:

ok 1 number(s): "0"

Test #99:

score: 0
Accepted
time: 12ms
memory: 15288kb

input:

2
0 0 2
2 0 0
2 0 0

output:

0

result:

ok 1 number(s): "0"

Test #100:

score: 0
Accepted
time: 10ms
memory: 15168kb

input:

2
1 0 1
0 0 2
0 1 1

output:

2

result:

ok 1 number(s): "2"

Test #101:

score: 0
Accepted
time: 12ms
memory: 15284kb

input:

2
0 0 2
2 0 0
0 0 2

output:

0

result:

ok 1 number(s): "0"

Test #102:

score: 0
Accepted
time: 16ms
memory: 15224kb

input:

3
1 0 2
0 1 2
2 1 0

output:

0

result:

ok 1 number(s): "0"