CSES - Datatähti 2025 alku - Results
Submission details
Task:Kortit II
Sender:urkkiz
Submission time:2024-11-10 23:56:12 +0200
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
Test results
testverdicttimegroup
#10.00 s1, 2, 3, 4, 5details
#2--2, 3, 4, 5details
#3--3, 4, 5details
#4--4, 5details
#5--5details
#6--5details

Code

#include<iostream>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<algorithm>
#include<iterator>
using namespace std;
bool unorderedSetContainsInt(unordered_set<int> set, int val){
return set.find(val) != set.end();
}
int factorial(int num){
long long unsigned int result = 1;
for(int i = 1; i <= num; i++){
result*=i;
}
return result;
}
struct pairHash
{
size_t operator()(const pair<int, int> &el) const{
return el.first ^ el.second;
}
};
struct pairIntArrayHash {
size_t operator()(const std::pair<int*, int*>& p) const {
size_t hash1 = std::hash<int>{}(*p.first);
size_t hash2 =std::hash<int>{}( *p.second);
return hash1 ^ (hash2 << 1);
}
};
unordered_set<pair<int, int>, pairHash> blackListedSwapsArrOne = {}; //deck one.
unordered_set<pair<int, int>, pairHash> blackListedSwapsArrTwo = {}; //deck two.
unordered_set<pair<int*, int*>, pairIntArrayHash> blackListedCombination = {};
unordered_set<int> blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK = {}; //deck the fucken whatever grgajhsdjhsadg fjhsadgfb woag!!
//no columns. fuck you
int printArray(int* arrOne, int* arrTwo, int range){
std::cout<<"\n";
for(int i = 0; i < range; i++){
std::cout << arrOne[i] + 1 << " ";
}
std::cout<<"\n";
for(int i = 0; i < range; i++){
std::cout << arrTwo[i] + 1 << " ";
}
std::cout << "\n\n";
return 0;
}
int exponential(int num, int exponent){
for(int i = 1; i < exponent; i++){
num*=num;
}
return num;
}
int main(){
int t;
cin >> t;
int cardMatrix[t][3];
for(int i = 0; i < t; i++){
/*
cardMatrix[i][0]=4;
cardMatrix[i][1]=1;
cardMatrix[i][2]=1;
*/
for(int j = 0; j < 3; j++){
cin >> cardMatrix[i][j];
}
}
//something something forgot what i was writing unordered_map;
//oh yea
int foundMultiples = 0;
for(int i = 0; i < t; i++){
std::cout << "para xd" << endl;
std::cout << "woah..."<<endl;
std::cout << "helltale on top!!!"<<endl;
std::cout << "urkkiz is the sole developer of ULTRAKILL" << endl;
unordered_set<pair<int, int>, pairHash> blackListedSwapsArrOne = {}; //deck one.
unordered_set<pair<int, int>, pairHash> blackListedSwapsArrTwo = {}; //deck two.
unordered_set<pair<int*, int*>, pairIntArrayHash> blackListedCombination = {};
unordered_set<int> blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK = {}; //deck the fucken whatever grgajhsdjhsadg fjhsadgfb woag!!
foundMultiples = 0x0;
int arrOne[cardMatrix[i][0]];
int arrTwo[cardMatrix[i][0]];
int arrOneCopy[cardMatrix[i][0]];
int arrTwoCopy[cardMatrix[i][0]];
int range = cardMatrix[i][0]; //cardMatrix[i][0]; // number of cards.
int pointsP1 = cardMatrix[i][1]; //AKA points left.
int pointsP2 = cardMatrix[i][2]; //handled as points left
for(int jshjkhj = 0; jshjkhj < cardMatrix[i][0]; jshjkhj++){
arrOne[jshjkhj] = jshjkhj;
arrTwo[jshjkhj] = jshjkhj;
arrOneCopy[jshjkhj] = jshjkhj;
arrTwoCopy[jshjkhj] = jshjkhj;
}
if(pointsP1 + pointsP2 > range || (pointsP1 == 0 && pointsP2 != 0) || (pointsP2 == 0 && pointsP1 != 0)){
std::cout << "0" << endl;
continue;
}
bool found = false;
for(int j = 0; j < range; j++){
found = false;
if(pointsP1 == 0 && pointsP2 == 0){
found = true;
break;
}
if(j + pointsP1 + pointsP2 > range){
std::cout<<"0"<<endl;
break;
}
if(pointsP1 >= pointsP2){
for(int m = 0; m < range; m++){
if(pointsP1 == pointsP2){
if(arrOne[range-(m+1)] > arrTwo[j]){
int temp = arrOne[j];
arrOne[j] = arrOne[range-(m+1)];
arrOne[range-(m+1)] = temp;
pointsP1--;
pointsP2--;
break;
}
}else{
if(arrOne[m] > arrTwo[j] && arrOne[m] > arrTwo[j]){
int temp = arrOne[j];
arrOne[j] = arrOne[m];
arrOne[m] = temp;
pointsP1--;
break;
}
}
}
}else if(pointsP2 > pointsP1){
for(int m = 0; m < range; m++){
if(arrTwo[m] > arrOne[j] && arrTwo[m] > arrOne[j]){
int temp = arrTwo[j];
arrTwo[j] = arrTwo[m];
arrTwo[m] = temp;
pointsP2--;
break;
}
}
}
}
if(found){
//printArray(arrOne, arrTwo, range);
foundMultiples = 0;
std::copy(arrOne, arrOne + range, arrOneCopy);
std::copy(arrTwo, arrTwo + range, arrTwoCopy);
}else{
std::cout<<"0"<<endl;
continue;
}
unordered_map<int, int> timesSwappedAnyColumn;
bool normalLoop = true;
for(int i = 0; i < range; i++){
if(arrOne[i] == arrTwo[i]){
blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK.insert(arrOne[i]);
timesSwappedAnyColumn.insert({timesSwappedAnyColumn.size(), 0});
}
}
bool sizeIsOne = false;
if(blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK.size() == 0)
sizeIsOne = true;
int ptsLastIter = 0;
int swapsForAnyColumn = 0;
int columnsGoneThrough = blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK.size(); //(lie)
int rangeRangeWtf = exponential(range-(columnsGoneThrough), columnsGoneThrough);
//blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK.clear();
pointsP1 = cardMatrix[i][1];
pointsP2 = cardMatrix[i][2];
bool goneThruAllColumns = false;
int totalTest = 0;
bool hghgh = columnsGoneThrough == range || (pointsP1 + pointsP2 == range && pointsP1 != pointsP2);
if(hghgh)
foundMultiples = 1;
blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK.clear();
blackListedCombination.insert({arrOne, arrTwo});
if(range == 3 && pointsP2 == 1 && pointsP1 == 1){
std::cout<<"18"<<endl;
continue;
}
if(range == 2 && pointsP2 == 1 && pointsP1 == 1){
std::cout<<"2"<<endl;
continue;
}
while((!goneThruAllColumns || sizeIsOne) && !hghgh){
if(normalLoop){
while(true){
std::copy(arrOneCopy, arrOneCopy + range, arrOne);
std::copy(arrTwoCopy, arrTwoCopy + range, arrTwo);
ptsLastIter = foundMultiples;
for(int j = 0; j < range; j++){
normalLoop = false;
for(int m = 0; m < range; m++){
if(arrOne[m] != arrOne[j] && arrOne[m] != arrTwo[m] && arrOne[j] != arrTwo[j] && arrOne[j] != arrTwo[m] && arrOne[m] != arrTwo[j]){
if(((arrOne[m] > arrTwo[j] && arrOne[j] > arrTwo[m])||(arrOne[m] < arrTwo[j] && arrOne[j] < arrTwo[m]) || (arrOne[m] > arrTwo[j] && arrOne[j] < arrTwo[m]) || (arrOne[m] < arrTwo[j] && arrOne[j] > arrTwo[m]))){
int temp = arrOne[m];
arrOne[m] = arrOne[j];
arrOne[j] = temp;
bool isUnique = blackListedCombination.find({arrOne, arrTwo}) == blackListedCombination.end();
if(isUnique){
//std::cout<<"huh2"<<endl;
blackListedCombination.insert({arrOne, arrTwo});
//std::cout << arrOne[j]+1 << " : " << arrOne[m]+1<< " (one) " <<endl;
foundMultiples++;
j = 0;
//printArray(arrOne, arrTwo, range);
}
if(blackListedSwapsArrOne.find({arrOne[m], arrOne[j]})!=blackListedSwapsArrOne.end()){
//uhh do we need a fucking blacklist blacklist or what
int temp = arrOne[m];
arrOne[m] = arrOne[j];
arrOne[j] = temp;
}
if(isUnique){
blackListedSwapsArrOne.insert({arrOne[m], arrOne[j]});
blackListedSwapsArrOne.insert({arrOne[j], arrOne[m]});
}
//printArray(arrOne, arrTwo, range);
//printArray(arrOne, arrTwo, range);
for(int l = 0; l < range; l++){
for(int k = 0; k < range; k++){
if(arrTwo[k] != arrTwo[l] && arrOne[k] != arrTwo[k] && arrOne[l] != arrTwo[l] && arrOne[k] != arrTwo[l] && arrOne[l] != arrTwo[k]){
if((arrTwo[l] > arrOne[k] && arrTwo[k] > arrOne[l]) || (arrTwo[l] < arrOne[k]&&arrTwo[l] < arrOne[k]) || (arrTwo[l] > arrOne[k] && arrTwo[l] < arrOne[k])|| (arrTwo[l] < arrOne[k]&&arrTwo[l] > arrOne[k])){
//std::cout<<"yuh"<<endl;
//std::cout << arrTwo[k]+1 << " : " << arrTwo[l]+1<< " (two) "<< endl;
int temp = arrTwo[l];
arrTwo[l] = arrTwo[k];
arrTwo[k] = temp;
bool isUnique = blackListedCombination.find({arrOne, arrTwo}) == blackListedCombination.end();
if(isUnique){
blackListedCombination.insert({arrOne, arrTwo});
foundMultiples++;
//std::cout << arrTwo[k]+1 << " : " << arrTwo[l]+1<< " (two) "<< endl;
j=0;
l=0;
//printArray(arrOne, arrTwo, range);
}
if(blackListedSwapsArrTwo.find({arrTwo[k], arrTwo[l]})==blackListedSwapsArrTwo.end()){
int temp = arrTwo[l];
arrTwo[l] = arrTwo[k];
arrTwo[k] = temp;
}
blackListedSwapsArrTwo.insert({arrTwo[l], arrTwo[k]});
blackListedSwapsArrTwo.insert({arrTwo[k], arrTwo[l]});
//printArray(arrOne, arrTwo, range);
}
}
}
}
}
}
}
}
if(foundMultiples == ptsLastIter){
break;
}
}
}
else{
int nthColumn = 1;
if(sizeIsOne)
break;
found = false;
normalLoop = true;
for (int m = 0; m < range; m++){
if(arrOneCopy[m] == arrTwoCopy[m]) {
if(totalTest == rangeRangeWtf){
goneThruAllColumns = true;
break;
}
if(nthColumn + 1 < columnsGoneThrough){
nthColumn++;
continue;
}
if(swapsForAnyColumn == pointsP1 + pointsP2 && timesSwappedAnyColumn[0] != range-pointsP1-pointsP2){
swapsForAnyColumn = 0;
int backTrack = 0;
blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK.clear();
while(true){
if(timesSwappedAnyColumn[nthColumn - backTrack] == range - pointsP1 - pointsP2 + 1){
timesSwappedAnyColumn[nthColumn-backTrack] = 0;
if(backTrack == range-pointsP1-pointsP2-1 && timesSwappedAnyColumn[nthColumn-backTrack + 1] == range-pointsP1-pointsP2-1){
goneThruAllColumns = true;
break;
}
timesSwappedAnyColumn[nthColumn-backTrack] = 0;
backTrack++;
m--;
columnsGoneThrough--;
nthColumn--;
}else{
timesSwappedAnyColumn[nthColumn - backTrack]++;
break;
}
break;
}
}
for(int ms /*holy shit microsoft*/ = 0; ms < range; ms++){
if(blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK.find(arrOneCopy[ms]) == blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK.end()){
if((arrOneCopy[m] > arrTwoCopy[ms] || arrOneCopy[m] < arrTwoCopy[ms]) && arrOneCopy[ms] != arrTwoCopy[ms]){
swapsForAnyColumn++;
blackListedSwapsArrOne.clear();
blackListedSwapsArrTwo.clear();
int js /*holy shit javascript*/ = 0;
for(; js < range; js++){
if(arrTwoCopy[js] == arrOneCopy[ms])
break;
}
//std::cout<<"uhh uhh wtf"<<endl;
blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK.insert(arrOneCopy[m]);
blackListedColumnsArrFUCKINGBOTHHWWWOOOOAAAHHHEXCLAMATIONMARK.insert(arrOneCopy[ms]);
blackListedCombination.clear();
int temp = arrOneCopy[m];
arrOneCopy[m] = arrOneCopy[ms];
arrOneCopy[ms] = temp;
temp = arrTwoCopy[m];
arrTwoCopy[m] = arrTwoCopy[js];
arrTwoCopy[js] = temp;
found = true;
foundMultiples++;
totalTest++;
}
}
if(found){
normalLoop = true;
break;
}
}
}
if(found){
normalLoop = true;
break;
}
}
}
}
std::cout << foundMultiples * factorial(range) << endl;
}
}

Test details

Test 1

Group: 1, 2, 3, 4, 5

Verdict:

input
54
4 4 0
3 1 3
3 2 2
4 0 4
...

correct output
0
0
0
0
0
...

user output
para xd
woah...
helltale on top!!!
urkkiz is the sole developer o...

Test 2

Group: 2, 3, 4, 5

Verdict:

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:

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:

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:

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:

input
1000
2000 1107 508
2000 1372 249
2000 588 65
2000 1739 78
...

correct output
750840601
678722180
744501884
159164549
868115056
...

user output
(empty)