Submission #669079

#TimeUsernameProblemLanguageResultExecution timeMemory
669079ktkeremHomework (CEOI22_homework)C++17
100 / 100
68 ms45384 KiB
/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/ #include<bits/stdc++.h> /**/ //typedef int ll; typedef long long ll; typedef unsigned long long ull; typedef std::string str; //typedef vector<std::vector<ll>> vv; /*typedef __int128 vll; typedef unsigned __int128 uvll;*/ #define llll std::pair<ll , ll> #define pb push_back #define pf push_front #define halo cout << "hello\n" #define fi first #define sec second #define vv(x) std::vector<std::vector<x>> #define all(a) a.begin() , a.end() const ll limit = 1e15+7; const ll ous = 1e6 + 7; const ll dx[4] = {-1 , 0 , 1 , 0} , dy[4] = {0,1,0,-1}; ll n;ll x = 0; ll ff = 0;std::string s; llll buildadj(){ if(s[x++] == '?'){ return {1 , n}; } char c = s[x]; x+=3; llll a = buildadj(); x++; llll b = buildadj(); x++; if(c == 'i'){ return {std::min(a.fi , b.fi) , a.sec + b.sec - n - 1}; } else{ return {a.fi + b.fi , std::max(a.sec , b.sec)}; } } /*llll dfs(ll crt , ll prv = -1){ if(typ[crt] == 0){ return{1 , n}; } else if(typ[crt] == 1){ std::vector<llll> v; for(auto j:adj[crt]){ if(j != prv){ v.pb(dfs(j , crt)); } } assert(v.size() >= 2); //std::cout << v.size() << std::endl; return {std::min(v[0].fi , v[1].fi) , v[0].sec + v[1].sec - n - 1}; } else{ std::vector<llll> v; for(auto j:adj[crt]){ if(j != prv){ v.pb(dfs(j , crt)); } } assert(v.size() >= 2); //std::cout << v.size() << std::endl; return {v[0].fi + v[1].fi , std::max(v[0].sec , v[1].sec)}; } return {0 , 0}; }*/ void solve(){ std::cin >> s; n= std::count(all(s) , '?'); llll ans = buildadj(); std::cout << ans.sec - ans.fi + 1 << "\n"; return; } signed main(){ std::ios_base::sync_with_stdio(false);std::cin.tie(NULL); ll t=1; //std::cin >> t; ll o = 1; while(t--){ solve(); } return 0; }/**/

Compilation message (stderr)

Main.cpp:5:78: warning: "/*" within comment [-Wcomment]
    5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
      |                                                                               
Main.cpp: In function 'int main()':
Main.cpp:84:8: warning: unused variable 'o' [-Wunused-variable]
   84 |     ll o = 1;
      |        ^
#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...