CSES - Datatähti 2025 alku - Results
Submission details
Task:Tikut
Sender:urkkiz
Submission time:2024-11-10 23:56:28 +0200
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
#60
Test results
testverdicttimegroup
#10.00 s1, 3, 4, 5, 6details
#20.37 s1, 4, 5, 6details
#30.37 s1, 4, 5, 6details
#40.37 s1, 4, 5, 6details
#5--2, 5, 6details
#6--2, 5, 6details
#7--3, 5, 6details
#8--3, 5, 6details
#9--3, 5, 6details
#10--3, 5, 6details
#11--3, 5, 6details
#12--4, 5, 6details
#130.37 s4, 5, 6details
#140.37 s4, 5, 6details
#150.37 s4, 5, 6details
#160.37 s5, 6details
#170.37 s5, 6details
#180.37 s5, 6details
#190.37 s5, 6details
#200.41 s6details
#210.39 s6details
#220.41 s6details

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, 3, 4, 5, 6

Verdict:

input
1 1
6

correct output

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

Test 2

Group: 1, 4, 5, 6

Verdict:

input
5 10
4 8 6 2 7

correct output
5 4 2 2 2 1 1 1 1 1 

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

Test 3

Group: 1, 4, 5, 6

Verdict:

input
5 10
5 5 8 6 7

correct output
3 3 2 3 2 2 1 1 1 2 

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

Test 4

Group: 1, 4, 5, 6

Verdict:

input
5 10
8 7 9 6 10

correct output
4 4 3 3 2 2 1 2 2 1 

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

Test 5

Group: 2, 5, 6

Verdict:

input
1000 1071
3 2 3 1 3 3 2 3 2 3 2 2 2 1 2 ...

correct output
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

user output
(empty)

Test 6

Group: 2, 5, 6

Verdict:

input
1000 1500
3 2 2 3 2 3 2 2 2 3 2 2 3 3 3 ...

correct output
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

user output
(empty)

Test 7

Group: 3, 5, 6

Verdict:

input
1000 2
15 710 210 347 398 66 318 277 ...

correct output
994 994 

user output
(empty)

Test 8

Group: 3, 5, 6

Verdict:

input
1000 2
743 890 592 942 736 969 616 50...

correct output
498 496 

user output
(empty)

Test 9

Group: 3, 5, 6

Verdict:

input
1000 2
987 968 920 994 988 918 914 95...

correct output
500 500 

user output
(empty)

Test 10

Group: 3, 5, 6

Verdict:

input
1000 2
996 1000 998 998 999 997 997 9...

correct output
500 500 

user output
(empty)

Test 11

Group: 3, 5, 6

Verdict:

input
1000 2
501 501 501 501 501 501 501 50...

correct output
1 168 

user output
(empty)

Test 12

Group: 4, 5, 6

Verdict:

input
100 200
145 136 74 83 73 36 196 115 11...

correct output
194 190 189 183 182 181 181 17...

user output
(empty)

Test 13

Group: 4, 5, 6

Verdict:

input
100 200
157 110 168 155 192 107 146 15...

correct output
95 96 96 95 93 94 94 94 90 91 ...

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

Test 14

Group: 4, 5, 6

Verdict:

input
50 200
137 118 160 118 146 160 140 18...

correct output
98 98 98 96 90 91 88 88 84 86 ...

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

Test 15

Group: 4, 5, 6

Verdict:

input
100 200
147 174 186 148 155 128 158 18...

correct output
99 99 98 98 97 97 96 96 95 95 ...

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

Test 16

Group: 5, 6

Verdict:

input
1000 2000
928772177 816188227 216592201 ...

correct output
991676844 990940224 990685481 ...

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

Test 17

Group: 5, 6

Verdict:

input
1000 2000
665759876 597950008 615453266 ...

correct output
498801198 498681904 498504321 ...

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

Test 18

Group: 5, 6

Verdict:

input
500 2000
683288817 784230412 626685186 ...

correct output
497667621 498434895 495465990 ...

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

Test 19

Group: 5, 6

Verdict:

input
1000 2000
666667000 809309500 571572000 ...

correct output
499499500 499249250 498999000 ...

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

Test 20

Group: 6

Verdict:

input
100000 200000
861772559 734298084 983382252 ...

correct output
499973914 499985299 499985141 ...

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

Test 21

Group: 6

Verdict:

input
30000 200000
691834579 617419813 514778075 ...

correct output
499967533 499976270 499969810 ...

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

Test 22

Group: 6

Verdict:

input
100000 200000
820255000 960780000 741965000 ...

correct output
499995000 499992500 499990000 ...

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