Submission #772665

#TimeUsernameProblemLanguageResultExecution timeMemory
772665Valters07Homework (CEOI22_homework)C++14
10 / 100
1068 ms13860 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") #define fio ios_base::sync_with_stdio(0);cin.tie(0); #define ll long long #define en cin.close();return 0; #define pb push_back #define fi first//printf("%lli\n",cur); #define se second//scanf("%lli",&n); using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> a; string str; int it; int go(int l, int r) { if(l==r) return a[it++]; int op = 0, pos = l+4; while(1) { if(str[pos]=='(') op++; else if(str[pos]==')') op--; else if(str[pos]==','&&op==0) break; pos++; } int l1 = go(l+4,pos-1), r1 = go(pos+1,r-1); return ((str[l+1]=='i')?min(l1,r1):max(l1,r1)); } int main() { fio // ifstream cin("in.in"); cin >> str; int n = 0; for(auto x:str) n+=(x=='?'); a.resize(n); iota(a.begin(),a.end(),1); set<int> ans; do { it=0; ans.insert(go(0,str.size()-1)); } while(next_permutation(a.begin(),a.end())); cout << ans.size(); // cout << endl;for(auto x:ans)cout << x << " "; // cin.close(); 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...