CSES - Datatähti 2024 loppu - Results
Submission details
Task:Sulut
Sender:andreibe
Submission time:2024-01-20 15:28:46 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:18:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   18 |         return;
      |         ^~~~~~
input/code.cpp:39:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   39 |         return;
      |         ^~~~~~

Code

#include <bits/stdc++.h>
using namespace std;
 
char ch[1100000];
char ch2[1100000];
 
vector<pair<char,char>> ans;
 
int main() {
    //ifstream in("input.txt");
    //cin.rdbuf(in.rdbuf());
 
    int n,k;
 
    cin >> n >> k;
    if ((k % 2 != 0) || (n % 2 != 0)) {
        cout << "IMPOSSIBLE\n";
        return;
    }
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0) ch[i] = '(';
        else ch[i] = ')';
    }
    cout << ch << "\n";
 
    for (int i = 1; i < n; i++) {
        if (k == 0) break;
        if (i == n-1) break;
 
        ch[i] = '(';
        ch[i+1] = ')';
 
        i++;
        k -= 2;
    }
    if (k != 0) {
        cout << "IMPOSSIBLE\n";
        return;
    }
    cout << ch;
}