제출 #244097

#제출 시각아이디문제언어결과실행 시간메모리
244097tonowakMatch (CEOI16_match)C++14
0 / 100
19 ms384 KiB
#include <bits/stdc++.h> // Tomasz Nowak using namespace std; // XIII LO Szczecin using LL = long long; // Poland #define FOR(i, l, r) for(int i = (l); i <= (r); ++i) #define REP(i, n) FOR(i, 0, (n) - 1) template<class T> int size(T &&x) { return int(x.size()); } template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) { return out << '(' << p.first << ", " << p.second << ')'; } template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) { out << '{'; for(auto it = x.begin(); it != x.end(); ++it) out << *it << (it == prev(x.end()) ? "" : ", "); return out << '}'; } void dump() {} template<class T, class... Args> void dump(T &&x, Args... args) { cerr << x << "; "; dump(args...); } #ifdef DEBUG struct Nl{~Nl(){cerr << '\n';}}; # define debug(x...) cerr << (#x != "" ? #x ": " : ""), dump(x), Nl(), cerr #else # define debug(...) 0 && cerr #endif mt19937_64 rng(0); int rd(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); } // end of templates int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; const int n = size(s); int answer = -1; REP(mask, 1 << n) { auto consider = [&] { vector<int> open; REP(i, n) if((mask >> i) & 1) { if(size(open) == 0) return; int l = open.back(); open.pop_back(); if(s[l] != s[i]) return; } else open.emplace_back(i); if(size(open)) return; debug(mask); answer = max(answer, mask); }; consider(); } if(answer == -1) cout << "-1\n"; else { REP(i, n) if((answer >> i) & 1) cout << ')'; else cout << '('; cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...