CSES - Datatähti 2024 loppu - Results
Submission details
Task:Sulut
Sender:stpn129
Submission time:2024-01-20 15:32:24 +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.01 s1, 2, 3details
#16ACCEPTED0.00 s1, 2, 3details
#17ACCEPTED0.00 s1, 2, 3details
#18ACCEPTED0.00 s1, 2, 3details
#19ACCEPTED0.00 s1, 2, 3details
#200.00 s2, 3details
#210.00 s2, 3details
#220.00 s2, 3details
#230.00 s2, 3details
#240.00 s2, 3details
#250.01 s3details
#260.01 s3details
#270.01 s3details
#280.01 s3details
#290.01 s3details

Compiler report

input/code.cpp: In function 'std::vector<int> to_bit(int, int)':
input/code.cpp:22:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |    while(res.size() < n) {
      |          ~~~~~~~~~~~^~~

Code

#include<bits/stdc++.h>
using namespace std;
 
void init_code(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
}

vector<int> to_bit (int n, int x) {
   vector<int> res;
   while (x != 0) {
      res.push_back(x & 1);
      x >>= 1;
   }
   
   reverse(res.begin(), res.end());

   while(res.size() < n) {
      res.push_back(0);
   }
   
   reverse(res.begin(), res.end());

   return res;
}

void solve() {
   int n, k;
   cin >> n >> k;

   int m = (1 << n);
   for (int i = 0; i < m; ++i) {
      vector<int> t = to_bit(n, i);
      int b = 0;
      for (int it = 0; it < n; ++it) {
         if (t[it] == 0) b++;
         else b--;
         if (b < 0) break;
      }
      if (b != 0) continue;
      for (int j = 0; j < m; ++j) {
         vector<int> s = to_bit(n, j);
         int b = 0;
         for (int it = 0; it < n; ++it) {
            if (s[it] == 0) b++;
            else b--;
            if (b < 0) break;
         }
         if (b != 0) continue;

         int dif = 0;
         for (int it = 0; it < n; ++it) {
            if (t[it] != s[it]) {
               dif++;
            }
         }

         if (dif == k) {
            for (int it = 0; it < n; ++it) {
               if (t[it] == 0) cout << '(';
               else cout << ')';
            }
            cout << '\n';
            for (int it = 0; it < n; ++it) {
               if (s[it] == 0) cout << '(';
               else cout << ')';
            }
            cout << '\n';
            return;
         }
      }
   }

   cout << "IMPOSSIBLE" << '\n';
}
 
int main() {
   init_code();
   solve();
   return 0;
}

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
IMPOSSIBLE

Test 21

Group: 2, 3

Verdict:

input
100 10

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

user output
IMPOSSIBLE

Test 22

Group: 2, 3

Verdict:

input
100 42

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

user output
IMPOSSIBLE

Test 23

Group: 2, 3

Verdict:

input
100 80

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

user output
IMPOSSIBLE

Test 24

Group: 2, 3

Verdict:

input
100 98

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

user output
IMPOSSIBLE

Test 25

Group: 3

Verdict:

input
1000000 0

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

user output
IMPOSSIBLE

Test 26

Group: 3

Verdict:

input
1000000 42

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

user output
IMPOSSIBLE

Test 27

Group: 3

Verdict:

input
1000000 4242

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

user output
IMPOSSIBLE

Test 28

Group: 3

Verdict:

input
1000000 424242

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

user output
IMPOSSIBLE

Test 29

Group: 3

Verdict:

input
1000000 999998

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

user output
IMPOSSIBLE