Submission details
Task:Sulkulauseke
Sender:Lieska
Submission time:2025-12-20 16:05:01 +0200
Language:C++ (C++20)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED20
#2ACCEPTED30
#3ACCEPTED50
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 s2, 3details
#14ACCEPTED0.00 s2, 3details
#15ACCEPTED0.00 s2, 3details
#16ACCEPTED0.00 s2, 3details
#17ACCEPTED0.00 s2, 3details
#18ACCEPTED0.01 s3details
#19ACCEPTED0.01 s3details
#20ACCEPTED0.01 s3details
#21ACCEPTED0.01 s3details
#22ACCEPTED0.01 s3details
#23ACCEPTED0.01 s3details
#24ACCEPTED0.01 s3details
#25ACCEPTED0.00 s2, 3details
#26ACCEPTED0.01 s3details
#27ACCEPTED0.00 s2, 3details
#28ACCEPTED0.01 s3details
#29ACCEPTED0.00 s2, 3details
#30ACCEPTED0.01 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:114:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  114 |     for (int i=0; i<s.size(); ++i){
      |                   ~^~~~~~~~~
input/code.cpp:131:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  131 |         for (int i=0; i<s1.size(); ++i){
      |                       ~^~~~~~~~~~

Code

//////// From bqi343
 
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = long double; // or double, if TL is tight
using str = string; // yay python! //
 
// pairs
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;
#define mp make_pair
#define f first
#define s second
 
#define tcT template<class T
#define tcTU tcT, class U
// ^ lol this makes everything look weird but I'll try it
tcT> using V = vector<T>; 
tcT, size_t SZ> using AR = array<T,SZ>; 
using vi = V<int>;
using vb = V<bool>;
using vl = V<ll>;
using vd = V<db>;
using vs = V<str>;
using vpi = V<pi>;
using vpl = V<pl>;
using vpd = V<pd>;
 
// vectors
// oops size(x), rbegin(x), rend(x) need C++17
#define sz(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend() 
#define sor(x) sort(all(x)) 
#define rsz resize
#define ins insert 
#define pb push_back
#define eb emplace_back
#define ft front()
#define bk back()
 
#define lb lower_bound
#define ub upper_bound
tcT> int lwb(V<T>& a, const T& b) { return int(lb(all(a),b)-bg(a)); }
tcT> int upb(V<T>& a, const T& b) { return int(ub(all(a),b)-bg(a)); }
 
// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rep(a) F0R(_,a)
#define each(a,x) for (auto& a: x)
 
const int MOD = (int)1e9+7; // 998244353;
const int MX = (int)2e5+5;
const ll BIG = 1e18; // not too close to LLONG_MAX
const db PI = acos((db)-1);
const int dx[4]{1,0,-1,0}, dy[4]{0,1,0,-1}; // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
template<class T> using pqg = priority_queue<T,vector<T>,greater<T>>;
 
// bitwise ops
// also see https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int bits(int x) { // assert(x >= 0); // make C++11 compatible until USACO updates ...
	return x == 0 ? 0 : 31-__builtin_clz(x); } // floor(log2(x)) 
constexpr int p2(int x) { return 1<<x; }
constexpr int msk2(int x) { return p2(x)-1; }
 
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down
 
tcT> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; } // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; } // set a = max(a,b)
 
tcTU> T fstTrue(T lo, T hi, U f) {
	++hi; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		T mid = lo+(hi-lo)/2;
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
	--lo; assert(lo <= hi); // assuming f is decreasing
	while (lo < hi) { // find first index such that f is true 
		T mid = lo+(hi-lo+1)/2;
		f(mid) ? lo = mid : hi = mid-1;
	} 
	return lo;
}
tcT> void remDup(vector<T>& v) { // sort and remove duplicates
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
tcTU> void erase(T& t, const U& u) { // don't erase
	auto it = t.find(u); assert(it != end(t));
	t.erase(it); } // element that doesn't exist from (multi)set


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	string s;
    cin >> s;

    string s1 = s;
    int cnt=0;
    for (int i=0; i<s.size(); ++i){
        if (s[i]=='(') cnt++;
        else if (s[i]==')') cnt--;
        else {
            cnt++;
            s1[i]='(';
        }
    }
    for (int i=s.size()-1; i>=0; --i){
        if (cnt && s[i]=='?'){
            cnt-=2;
            s1[i]=')';
        }
    }
    if (cnt) cout << "IMPOSSIBLE\n";
    else{
        int cnt1 = 0;
        for (int i=0; i<s1.size(); ++i){
            if (s1[i]=='(') cnt1++;
            else cnt1--;
            if (cnt1<0) {
                cout << "IMPOSSIBLE\n";
                return 0;
            }
        }
        cout << s1 << "\n";
    }
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
?

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
??

correct output
()

user output
()

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

input
(()

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
((()

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
())(

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 6

Group: 1, 2, 3

Verdict: ACCEPTED

input
)???

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

input
()?(

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 8

Group: 1, 2, 3

Verdict: ACCEPTED

input
()(())(())

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

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

Test 9

Group: 1, 2, 3

Verdict: ACCEPTED

input
?)(())(()?

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

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

Test 10

Group: 1, 2, 3

Verdict: ACCEPTED

input
(?))?(()))

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

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

Test 11

Group: 1, 2, 3

Verdict: ACCEPTED

input
(?)((?????

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

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

Test 12

Group: 1, 2, 3

Verdict: ACCEPTED

input
??????????

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

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

Test 13

Group: 2, 3

Verdict: ACCEPTED

input
((((()))))(((())()()())()(()))...

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

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

Test 14

Group: 2, 3

Verdict: ACCEPTED

input
()(??()?(?()?()???())??)???(((...

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

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

Test 15

Group: 2, 3

Verdict: ACCEPTED

input
?()?()(((()?))(()????)()(???)?...

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

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

Test 16

Group: 2, 3

Verdict: ACCEPTED

input
???)?????(????(????)??????????...

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

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

Test 17

Group: 2, 3

Verdict: ACCEPTED

input
??????????????????????????????...

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

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

Test 18

Group: 3

Verdict: ACCEPTED

input
((((()(()()))))()())()()(((())...

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

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

Test 19

Group: 3

Verdict: ACCEPTED

input
(((()((()((()())(?)((())?(()??...

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

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

Test 20

Group: 3

Verdict: ACCEPTED

input
()?????)??()?(??)???()????)))?...

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

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

Test 21

Group: 3

Verdict: ACCEPTED

input
????(????)???)??)???()???????(...

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

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

Test 22

Group: 3

Verdict: ACCEPTED

input
??????????????????????????????...

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

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

Test 23

Group: 3

Verdict: ACCEPTED

input
((((((((((((((((((((((((((((((...

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

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

Test 24

Group: 3

Verdict: ACCEPTED

input
??????????????????????????????...

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

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

Test 25

Group: 2, 3

Verdict: ACCEPTED

input
((((((((((((((((((((((((((((((...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 26

Group: 3

Verdict: ACCEPTED

input
((((((((((((((((((((((((((((((...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 27

Group: 2, 3

Verdict: ACCEPTED

input
)?????????????????????????????...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 28

Group: 3

Verdict: ACCEPTED

input
)?????????????????????????????...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 29

Group: 2, 3

Verdict: ACCEPTED

input
??????????????????????????????...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 30

Group: 3

Verdict: ACCEPTED

input
??????????????????????????????...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE