Submission #223040

# Submission time Handle Problem Language Result Execution time Memory
223040 2020-04-14T14:42:28 Z Minnakhmetov Match (CEOI16_match) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;

    int n = s.size();

    vector<char> stk;

    reverse(all(s));

    string ans;

    for (char c : s) {
    	if (stk.empty() || stk.back() != c) {
    		stk.push_back(c);
    		ans.push_back(')');
    	}
    	else {
    		stk.pop_back();
    		ans.push_back('(');
    	}
    }

    reverse(all(ans));

    if (stk.empty()) {
        cout << ans << "\n";
    }
    else {
        cout << "-1\n";
    }
 
    return 0;
}

Compilation message

match.cpp: In function 'int main()':
match.cpp:14:9: warning: unused variable 'n' [-Wunused-variable]
     int n = s.size();
         ^
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -