CSES - Datatähti 2024 loppu - Results
Submission details
Task:Sulut
Sender:Vludo
Submission time:2024-01-20 15:44:45 +0200
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED51
#3ACCEPTED37
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
#20ACCEPTED0.00 s2, 3details
#21ACCEPTED0.00 s2, 3details
#22ACCEPTED0.00 s2, 3details
#23ACCEPTED0.00 s2, 3details
#24ACCEPTED0.00 s2, 3details
#25ACCEPTED0.01 s3details
#26ACCEPTED0.01 s3details
#27ACCEPTED0.01 s3details
#28ACCEPTED0.01 s3details
#29ACCEPTED0.01 s3details

Code

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i<n; i++)
#define FOR(i, k, n) for (int i = k; i < n; i++)
#define N 1<<17
#define pb push_back
typedef long long ll;
using namespace std;

int n, k;
string s;
int avattuna = 0, sul = 0;

int main() {
    cin >> n >> k;

    if ((n&1) || (k&1) || k>n-2) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    

    if (k <= n/2) {

        forn(i, n/2) s.pb('(');
        FOR(i, n/2, n) s.pb(')');
        cout << s << endl;

        FOR(i, 0, k/2) {
            s[((i+1)*2)-1] = ')';
            s[n-(i+1)*2] = '(';
        }
        cout << s << endl;
        return 0;
    }

    forn(i, n) {
        if (i&1) s.pb(')');
        else s.pb('(');
    }

    cout << s << endl;

    FOR(i, 1, k/2+1) {
        if (s[i] == '(') s[i] = ')';
        else s[i] = '(';
        if (s[n-1-i] == '(') s[n-1-i] = ')';
        else s[n-1-i] = '(';
    }
    cout << s << endl;
}

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: ACCEPTED

input
100 0

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

user output
((((((((((((((((((((((((((((((...
Truncated

Test 21

Group: 2, 3

Verdict: ACCEPTED

input
100 10

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

user output
((((((((((((((((((((((((((((((...
Truncated

Test 22

Group: 2, 3

Verdict: ACCEPTED

input
100 42

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

user output
((((((((((((((((((((((((((((((...
Truncated

Test 23

Group: 2, 3

Verdict: ACCEPTED

input
100 80

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

user output
()()()()()()()()()()()()()()()...
Truncated

Test 24

Group: 2, 3

Verdict: ACCEPTED

input
100 98

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

user output
()()()()()()()()()()()()()()()...
Truncated

Test 25

Group: 3

Verdict: ACCEPTED

input
1000000 0

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

user output
((((((((((((((((((((((((((((((...
Truncated

Test 26

Group: 3

Verdict: ACCEPTED

input
1000000 42

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

user output
((((((((((((((((((((((((((((((...
Truncated

Test 27

Group: 3

Verdict: ACCEPTED

input
1000000 4242

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

user output
((((((((((((((((((((((((((((((...
Truncated

Test 28

Group: 3

Verdict: ACCEPTED

input
1000000 424242

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

user output
((((((((((((((((((((((((((((((...
Truncated

Test 29

Group: 3

Verdict: ACCEPTED

input
1000000 999998

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

user output
()()()()()()()()()()()()()()()...
Truncated