Submission #936472

#TimeUsernameProblemLanguageResultExecution timeMemory
936472sebasvp2005Homework (CEOI22_homework)C++17
100 / 100
195 ms23004 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int #define endl '\n' void solve(){ stack<int> op; stack<pair<int,int>> num; string s;cin>>s; int n=0; for(auto e: s)if(e=='?')n++; for(int i=0;i<s.size(); i++){ if(s[i]=='i'){ op.push(0); } if(s[i]=='a'){ op.push(1); } if(s[i]=='?') { num.push({1,n}); } if(s[i]==')'){ auto a = num.top();num.pop(); auto b = num.top();num.pop(); int o = op.top(); op.pop(); if(o){ num.push({a.first + b.first , max(a.second, b.second)}); } else{ num.push({min(a.first, b.first), a.second+b.second-n-1}); } } } auto ans = num.top(); cout << ans.second - ans.first + 1 << endl; } int main(){ int t=1;//cin>>t; while(t--){ solve(); } }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:13:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   for(int i=0;i<s.size(); i++){
      |               ~^~~~~~~~~
#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...