# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476128 | 2021-09-24T21:43:49 Z | elgamalsalman | Match (CEOI16_match) | C++14 | 2 ms | 332 KB |
#include <bits/stdc++.h> using namespace std; int n; string s; bool validate(int l, int r) { //cerr << "// validate(" << l << ", " << r << ")\n"; if (r < l) return 1; int ind = 0; for (int i = l + 1; i <= r; i++) { if (s[l] == s[i]) ind = i; } if (!ind) return 0; s[l] = '('; s[ind] = ')'; return (validate(l + 1, ind - 1) && validate(ind + 1, r)); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); freopen("match.in", "r", stdin); freopen("match.out", "w", stdout); cin >> s; n = (int)s.size(); if (!validate(0, n - 1)) cout << "-1\n"; else cout << s << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |