Submission #703072

#TimeUsernameProblemLanguageResultExecution timeMemory
703072PenguinsAreCuteHomework (CEOI22_homework)C++17
53 / 100
1075 ms33628 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define MP make_pair int main() { int N = 0; string S; cin >> S; for(int i = 0; i < S.size(); i++) if(S[i] == 63) N++; pair<pair<int,int>,bool> data[N - 1]; pair<int,int> value[N]; value[N - 1] = make_pair(1, N); int cnt = 0; for(int i = 0; i < S.size(); i++) { if(S[i] == 109) { data[cnt].s = (S[i + 1] == 97); if(S[i + 4] == 63) data[cnt].f.f = N - 1; else data[cnt].f.f = cnt + 1; int j = i + 3, bC = 0, mC = 0; while(S[j] != 44 || bC != 0) { j++; if(S[j] == 109) mC++; if(S[j] == 40) bC++; else if(S[j] == 41) bC--; } if(S[j + 1] == '?') data[cnt].f.s = N - 1; else data[cnt].f.s = cnt + mC + 1; cnt++; } } for(int i = N - 2; i >= 0; i--) { if(data[i].s == false) { value[i].f = min(value[data[i].f.f].f, value[data[i].f.s].f); value[i].s = value[data[i].f.f].s + value[data[i].f.s].s - (N + 1); } else { value[i].f = value[data[i].f.f].f + value[data[i].f.s].f; value[i].s = max(value[data[i].f.f].s, value[data[i].f.s].s); } } cout << value[0].second - value[0].first + 1; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:8:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i = 0; i < S.size(); i++) if(S[i] == 63) N++;
      |                    ~~^~~~~~~~~~
Main.cpp:12:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i = 0; i < S.size(); i++) {
      |                    ~~^~~~~~~~~~
Main.cpp:9:30: warning: argument to variable-length array is too large [-Wvla-larger-than=]
    9 |     pair<pair<int,int>,bool> data[N - 1]; pair<int,int> value[N];
      |                              ^~~~
Main.cpp:9:30: note: limit is 9223372036854775807 bytes, but argument is 18446744073709551604
#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...