Task: | Kortit II |
Sender: | ma100 |
Submission time: | 2024-11-09 19:47:16 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 3 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 3 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
#4 | TIME LIMIT EXCEEDED | 0 |
#5 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2, 3, 4, 5 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3, 4, 5 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3, 4, 5 | details |
#4 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
#5 | TIME LIMIT EXCEEDED | -- | 5 | details |
#6 | TIME LIMIT EXCEEDED | -- | 5 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:89:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result] 89 | scanf("%d", &tc); | ~~~~~^~~~~~~~~~~ input/code.cpp:94:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result] 94 | scanf("%d %d %d", &n, &a, &b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Code
#include <bits/stdc++.h>using namespace std;typedef array<int, 3> ti;class N{public:N *p;int v;N(N *pv, int vv) : p(pv), v(vv) {};};ti f(int x, int y){ti p = {0, 0, 0};if (x == y){p[2] = 1;}else if (x > y){p[0] = 1;}else{p[1] = 1;}return p;}ti tp;long long int pop(N *rn, vector<int> ad, vector<int> bd, ti gt){int c = 0;int as = ad.size();int bs = bd.size();if (as == bs){if (rn && rn->p){ti ts = f(rn->p->v, rn->v);gt[0] += ts[0];gt[1] += ts[1];gt[2] += ts[2];if (gt[0] > tp[0] || gt[1] > tp[1] || gt[2] > tp[2]){return 0;}}if (as == 0){if (gt == tp){return c+1;}}for (int i = 0; i < as; i++){vector<int> an = ad;int v = an[i];an.erase(an.begin() + i);N *nn = new N(rn, v);int fi = pop(nn, an, bd, gt);c+=fi;}}else{for (int i = 0; i < bs; i++){vector<int> bn = bd;int v = bn[i];bn.erase(bn.begin() + i);N *nn = new N(rn, v);int fi = pop(nn, ad, bn, gt);c+=fi;}}return c;}int main(){ios_base::sync_with_stdio(0);cin.tie(0);int tc;scanf("%d", &tc);array<int, 3> cl[tc];for (int i = 0; i < tc; i++){int n, a, b;scanf("%d %d %d", &n, &a, &b);cl[i] = {n, a, b};}for (int x = 0; x < tc; x++){array<int, 3> s = cl[x];int n = s[0];int a = s[1];int b = s[2];tp = {a, b, n - a - b};vector<int> d;d.reserve(n);for (int i = 1; i <= n; i++){d.push_back(i);}N *rn = new N((N *)NULL, 0);long long int p = pop(rn, d, d, {0, 0, 0});p %= 1000000007;printf("%lld\n", p);}}
Test details
Test 1
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
input |
---|
54 4 4 0 3 1 3 3 2 2 4 0 4 ... |
correct output |
---|
0 0 0 0 0 ... |
user output |
---|
0 0 0 0 0 ... |
Test 2
Group: 2, 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
284 6 1 0 5 0 2 7 1 5 7 7 5 ... |
correct output |
---|
0 0 35280 0 36720 ... |
user output |
---|
(empty) |
Test 3
Group: 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
841 19 3 12 19 19 13 19 7 13 20 11 15 ... |
correct output |
---|
40291066 0 0 0 0 ... |
user output |
---|
(empty) |
Test 4
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 15 12 6 7 1 6 44 4 26 6 6 5 ... |
correct output |
---|
0 5040 494558320 0 340694548 ... |
user output |
---|
(empty) |
Test 5
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 892 638 599 966 429 655 1353 576 1140 1403 381 910 ... |
correct output |
---|
0 0 0 249098285 0 ... |
user output |
---|
(empty) |
Test 6
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 2000 1107 508 2000 1372 249 2000 588 65 2000 1739 78 ... |
correct output |
---|
750840601 678722180 744501884 159164549 868115056 ... |
user output |
---|
(empty) |