Task: | Kortit II |
Sender: | nikke5 |
Submission time: | 2024-10-31 19:53:15 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 8 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 3 |
#2 | ACCEPTED | 5 |
#3 | TIME LIMIT EXCEEDED | 0 |
#4 | TIME LIMIT EXCEEDED | 0 |
#5 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
#2 | ACCEPTED | 0.08 s | 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 'void combinations2()': input/code.cpp:124:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare] 124 | if (temp2.size() == globalN){ | ~~~~~~~~~~~~~^~~~~~~~~~ input/code.cpp:137:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 137 | for (int i = 0; i<temp.size(); i++){ | ~^~~~~~~~~~~~ input/code.cpp: In function 'int main()': input/code.cpp:254:12: warning: unused variable 'tasapelit' [-Wunused-variable] 254 | ll tasapelit = n-a-b; | ^~~~~~~~~
Code
#include <iostream>#include <cmath>#include <vector>#include <algorithm>#include <string>#include <sstream>typedef long long ll;using namespace std;ll kertoma(int x){for(int i = x-1; i>0; i--){x *= i;}return x;}ll binomikerroin(int x, int y){// Base Casesif (y > x)return 0;if (y == 0 || y == x)return 1;// Recurreturn binomikerroin(x - 1, y - 1)+ binomikerroin(x - 1, y);}vector<int> temp;vector<int> temp2;int p[1000001];int p2[1000001];int globalA;int globalB;int globalN;int vastaus = 0;int globalTesti;// void combinations2(int level, int n){// for (int i = 1; i <= n; i++){// if (temp2.size() <= level){// temp2.push_back(i);// }// else{// temp2[level] = i;// }// if (level >= n){// // THIS COUTS ALL POSSIBLE COMBINATIONS// // for (int i2 = 0; i2<temp.size(); i2++){// // cout << temp[i2] << " ";// // }// // cout << ", ";// // for (int i2 = 0; i2<temp2.size(); i2++){// // cout << temp2[i2] << " ";// // }// // cout << "\n \n";// int a = 0;// int b = 0;// int temp1amount = 0;// int temp2amount = 0;// for (int i2 = 0; i2<temp.size(); i2++){// if (temp[i2] > temp2[i2]){// a++;// }// else if (temp[i2] < temp2[i2]){// b++;// }// temp1amount += temp[i2];// temp2amount += temp2[i2];// }// if (a == globalA && b == globalB){// if (temp1amount == kertoma(n) && temp2amount == kertoma(n)){// vastaus ++;// }// }// }// else{// combinations2(level+1, n);// }// }// if (level >= n) return;// }// void combinations(int level, int n){// for (int i = 1; i <= n; i++){// if (temp.size() <= level){// temp.push_back(i);// }// else{// temp[level] = i;// }// if (level >= n){// // for (int i2 = 0; i<temp.size(); i++){// // cout << temp[i] << " ";// // }// // cout << "\n";// combinations2(0,n);// }// else{// combinations(level+1, n);// }// }// if (level >= n) return;// }void combinations2(){if (temp2.size() == globalN){// for (int i = 0; i<temp.size(); i++){// cout << temp[i] << " ";// }// cout << "\n";// for (int i = 0; i<temp2.size(); i++){// cout << temp2[i] << " ";// }// cout << "\n \n";int a = 0;int b = 0;for (int i = 0; i<temp.size(); i++){if (temp[i] > temp2[i]){a++;}else if (temp[i] < temp2[i]){b++;}}if (a == globalA && b == globalB){vastaus++;// for (int i = 0; i < temp.size(); i++)// {// cout << temp[i] << " ";// }// cout << "\n";// for (int i = 0; i < temp2.size(); i++)// {// cout << temp2[i] << " ";// }// cout << "\n \n";// if (temp2[0] == 8){// globalTesti++;// };}}else {for(int i = 1; i<=globalN; i++){if (p2[i]) continue;p2[i] = 1;temp2.push_back(i);combinations2();p2[i] = 0;temp2.pop_back();}}}void combinations(){// if (temp.size() == globalN){// // for (int i = 0; i<temp.size(); i++){// // cout << temp[i] << " ";// // }// // cout << "\n";// combinations2();// }// else {// for(int i = 1; i<=globalN; i++){// if (p[i]) continue;// p[i] = 1;// temp.push_back(i);// combinations();// p[i] = 0;// temp.pop_back();// }// }for (int i = 1; i<=globalN; i++){temp.push_back(i);}combinations2();temp.clear();temp2.clear();}int main() {int t;cin >> t;vector<int> nA;vector<int> aA;vector<int> bA;for (int i = 0; i<t; i++){int n, a, b;cin >> n >> a >> b;nA.push_back(n);aA.push_back(a);bA.push_back(b);}for (int i =0; i<t; i++){int n = nA[i], a = aA[i], b = bA[i];if (a != 0 && b != 0){if (a+b > n){cout << "0" << "\n";continue;}}else if (a+b != 0){cout << "0" << "\n";continue;}ll tasapelit = n-a-b;// ll tasapeliparit; // Tämä lasketaan binomikertoimella, eli kuinka monta kertaa joukosta N voi ottaa <tasapelit> verran numeroita// // BINOMIKERROINLASKU:// if (tasapelit == 0){// tasapeliparit = 1;// }// else if (tasapelit == 1){// tasapeliparit = n;// }// else{// tasapeliparit = kertoma(n)/(kertoma(tasapelit)*kertoma(n-tasapelit));// }// ll loput = kertoma(n-tasapelit-1);// ll vastaus = ((loput*tasapeliparit))*kertoma(n);// cout << tasapeliparit << " " << tasapelit << " " << n << " " << vastaus;// temp.push_back(0);// temp2.push_back(0);globalA = a;globalB = b;globalN = n;vastaus = 0;// combinations();// cout << vastaus*kertoma(n) << "\n";int KaavaVastaus = -1;if (a == 0 && b == 0){KaavaVastaus = kertoma(n);}else if (a == 1 || b == 1){KaavaVastaus = binomikerroin(n, n-a-b) * 1 * kertoma(n);}// else{// int loputYhdistelmat;// }if (KaavaVastaus != -1){cout << KaavaVastaus << "\n";}else{combinations();cout << vastaus*kertoma(n) << "\n";}// cout << "KAAVAVASTAUS:" << KaavaVastaus << "\n";// cout << "Luku / n!: " << vastaus << "\n";// cout << "Luku / tasapelimahkut: " << vastaus / binomikerroin(n, n-a-b) << "\n";// cout << "GLOBAL TESTI: " << globalTesti;// temp.clear();// temp2.clear();}}
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: ACCEPTED
input |
---|
284 6 1 0 5 0 2 7 1 5 7 7 5 ... |
correct output |
---|
0 0 35280 0 36720 ... |
user output |
---|
0 0 35280 0 36720 ... |
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) |