Submission #1164091

#TimeUsernameProblemLanguageResultExecution timeMemory
1164091santi3223Security Gate (JOI18_security_gate)C++17
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vl vector<ll> #define vs vector<string> #define vb vector<bool> #define vc vector<char> #define ull unsigned long long #define pll pair<ll, ll> #define pb push_back #define fi first #define se second #define ff(i, p, x) for(ll i = p; i < x; i++) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define ed "\n" #define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll MOD = 1e9+7; vl pos; ll cc = 0, n; bool check(string s){ ll c = 0; ff(i, 0, s.size()){ if(s[i] == '('){ c++; } else{ c--; } if(c < 0){ return false; } } if(c != 0){ return false; } return true; } set<string> st; void recur(string s, ll p){ if(p == pos.size()){ ff(l, 0, n){ ff(r, l, n){ ll ac = l; string cur = s; while(ac <= r){ if(cur[ac] == '('){ cur[ac] = ')'; } else{ cur[ac] = '('; } ac++; } if(check(cur)){ ll prev = st.size(); st.insert(s); if(st.size() != prev){ //cout << l << " " << r << ed; //cout << s << " " << cur << ed; cc++; } } } } } else{ string cur = s; cur[pos[p]] = '('; recur(cur, p+1); cur[pos[p]] = ')'; recur(cur, p+1); } } int main(){ IO cin >> n; string str; cin >> str; ff(i, 0, n){ if(str[i] == 'x'){ pos.pb(i); } } recur(str, 0); cout << cc; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...