Submission #867178

#TimeUsernameProblemLanguageResultExecution timeMemory
867178PagodePaivaHomework (CEOI22_homework)C++17
100 / 100
438 ms124568 KiB
#include<bits/stdc++.h> using namespace std; string s; map <int, int> virgulas; int solve(int l, int r){ if(l == r){ return 1; } int con = 0; int mid = virgulas[l]; int a = solve(l+4, mid-1); int b = solve(mid+1, r-1); if(s[l+1] == 'i'){ return min(a, b); } return a+b; } int solve2(int l, int r){ // cout << l << ' ' << r << '\n'; if(l == r){ return 1; } int con = 0; int mid = virgulas[l]; int a = solve2(l+4, mid-1); int b = solve2(mid+1, r-1); if(s[l+1] == 'a'){ return min(a, b); } return a+b; } int main(){ cin >> s; int con = 0; stack <int> q; for(int i = 0;i < s.size();i++){ if(s[i] == '?') con++; if(s[i] == 'm') q.push(i); if(s[i] == ')') q.pop(); if(s[i] == ',') virgulas[q.top()] = i; } int a = solve(0, s.size()-1); int b = solve2(0, s.size()-1); b = con-b+1; cout << b-a+1 << '\n'; }

Compilation message (stderr)

Main.cpp: In function 'int solve(int, int)':
Main.cpp:13:9: warning: unused variable 'con' [-Wunused-variable]
   13 |     int con = 0;
      |         ^~~
Main.cpp: In function 'int solve2(int, int)':
Main.cpp:32:9: warning: unused variable 'con' [-Wunused-variable]
   32 |     int con = 0;
      |         ^~~
Main.cpp: In function 'int main()':
Main.cpp:51:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     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...