CSES - Datatähti 2024 loppu - Results
Submission details
Task:Sulut
Sender:MikaelM
Submission time:2024-01-20 14:28:45 +0200
Language:C++ (C++17)
Status:READY
Result:12
Feedback
groupverdictscore
#1ACCEPTED12
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3details
#2ACCEPTED0.00 s1, 2, 3details
#3ACCEPTED0.00 s1, 2, 3details
#4ACCEPTED0.00 s1, 2, 3details
#5ACCEPTED0.00 s1, 2, 3details
#6ACCEPTED0.00 s1, 2, 3details
#7ACCEPTED0.00 s1, 2, 3details
#8ACCEPTED0.00 s1, 2, 3details
#9ACCEPTED0.00 s1, 2, 3details
#10ACCEPTED0.00 s1, 2, 3details
#11ACCEPTED0.00 s1, 2, 3details
#12ACCEPTED0.00 s1, 2, 3details
#13ACCEPTED0.00 s1, 2, 3details
#14ACCEPTED0.00 s1, 2, 3details
#15ACCEPTED0.00 s1, 2, 3details
#16ACCEPTED0.00 s1, 2, 3details
#17ACCEPTED0.00 s1, 2, 3details
#18ACCEPTED0.00 s1, 2, 3details
#19ACCEPTED0.00 s1, 2, 3details
#20--2, 3details
#21--2, 3details
#22--2, 3details
#23--2, 3details
#24--2, 3details
#25--3details
#26--3details
#27--3details
#28--3details
#29--3details

Code

#include<bits/stdc++.h>
using namespace std;
using ll = long long;



bool valid(string s){

    int x = 0;
    for(char c : s){
        if(c == '('){
            x++;
        }
        else{
            if(x == 0) return false;
            x--;
        }
    }

    return true;

}


int main(){

    ios_base::sync_with_stdio(0); cin.tie(0);

    
    int n, k;
    cin >> n >> k;

    if(n % 2 == 1 || k % 2 == 1){
        cout << "IMPOSSIBLE";
        return 0;
    }

    string s = "";

    for(int i = 1; i <= n; i++){
        s += (i <= n/2 ? "(" : ")");
    }
    
    vector<string> v;

   sort(s.begin(), s.end());

   do{

        if(!valid(s)) continue;

        v.push_back(s);

   }while(next_permutation(s.begin(), s.end()));




   for(string s1 : v){
        for(string s2 : v){

            int u = 0;
            for(int i = 0; i < n; i++){
                if(s1[i] != s2[i]) u++;
            }

            if(u == k){
                cout << s1 << "\n" << s2;
                return 0;
            }

        }
   }

   cout << "IMPOSSIBLE";






}

/*
(())

(((((()))())
()()((((()))))

(())()
((()))

*/

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
2 0

correct output
()
()

user output
()
()

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
4 0

correct output
()()
()()

user output
(())
(())

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

input
4 2

correct output
()()
(())

user output
(())
()()

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
6 0

correct output
()()()
()()()

user output
((()))
((()))

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
6 2

correct output
()()()
()(())

user output
((()))
(()())

Test 6

Group: 1, 2, 3

Verdict: ACCEPTED

input
6 4

correct output
()()()
(()())

user output
(()())
()()()

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

input
8 0

correct output
()()()()
()()()()

user output
(((())))
(((())))

Test 8

Group: 1, 2, 3

Verdict: ACCEPTED

input
8 2

correct output
()()()()
()()(())

user output
(((())))
((()()))

Test 9

Group: 1, 2, 3

Verdict: ACCEPTED

input
8 4

correct output
()()()()
()(()())

user output
(((())))
(())(())

Test 10

Group: 1, 2, 3

Verdict: ACCEPTED

input
8 6

correct output
()()()()
(()()())

user output
(()()())
()()()()

Test 11

Group: 1, 2, 3

Verdict: ACCEPTED

input
10 0

correct output
()()()()()
()()()()()

user output
((((()))))
((((()))))

Test 12

Group: 1, 2, 3

Verdict: ACCEPTED

input
10 2

correct output
()()()()()
()()()(())

user output
((((()))))
(((()())))

Test 13

Group: 1, 2, 3

Verdict: ACCEPTED

input
10 4

correct output
()()()()()
()()(()())

user output
((((()))))
((())(()))

Test 14

Group: 1, 2, 3

Verdict: ACCEPTED

input
10 6

correct output
()()()()()
()(()()())

user output
(((()())))
(())()(())

Test 15

Group: 1, 2, 3

Verdict: ACCEPTED

input
10 8

correct output
()()()()()
(()()()())

user output
(()()()())
()()()()()

Test 16

Group: 1, 2, 3

Verdict: ACCEPTED

input
4 1

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 17

Group: 1, 2, 3

Verdict: ACCEPTED

input
4 4

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 18

Group: 1, 2, 3

Verdict: ACCEPTED

input
5 1

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 19

Group: 1, 2, 3

Verdict: ACCEPTED

input
5 2

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 20

Group: 2, 3

Verdict:

input
100 0

correct output
()()()()()()()()()()()()()()()...

user output
(empty)

Test 21

Group: 2, 3

Verdict:

input
100 10

correct output
()()()()()()()()()()()()()()()...

user output
(empty)

Test 22

Group: 2, 3

Verdict:

input
100 42

correct output
()()()()()()()()()()()()()()()...

user output
(empty)

Test 23

Group: 2, 3

Verdict:

input
100 80

correct output
()()()()()()()()()()()()()()()...

user output
(empty)

Test 24

Group: 2, 3

Verdict:

input
100 98

correct output
()()()()()()()()()()()()()()()...

user output
(empty)

Test 25

Group: 3

Verdict:

input
1000000 0

correct output
()()()()()()()()()()()()()()()...

user output
(empty)

Test 26

Group: 3

Verdict:

input
1000000 42

correct output
()()()()()()()()()()()()()()()...

user output
(empty)

Test 27

Group: 3

Verdict:

input
1000000 4242

correct output
()()()()()()()()()()()()()()()...

user output
(empty)

Test 28

Group: 3

Verdict:

input
1000000 424242

correct output
()()()()()()()()()()()()()()()...

user output
(empty)

Test 29

Group: 3

Verdict:

input
1000000 999998

correct output
()()()()()()()()()()()()()()()...

user output
(empty)