Submission #781147

#TimeUsernameProblemLanguageResultExecution timeMemory
781147OzyHomework (CEOI22_homework)C++17
0 / 100
114 ms118648 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define repa(i,a,b) for(int i = (a); i >= (b); i--) #define pll pair<lli,lli> struct x { lli tipo; lli h[2]; lli apu; lli res; lli tam; }; string st; lli pos,cont,a; stack<lli> pila; vector<x> nodos; x trash; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> st; pos = 0; cont = 1; nodos.push_back(trash); pila.push(0); while (pos < st.size()) { //debugsl(pos); //debug(st[pos]); a = nodos[ pila.top() ].apu++; nodos[ pila.top() ].h[a] = cont; nodos.push_back(trash); pila.push(cont); if(st[pos] == 'm') { if (st[pos+1] == 'i') nodos[cont].tipo = 1; else nodos[cont].tipo = 2; cont++; pos += 4; continue; } nodos[cont].tam = 1; nodos[cont].res = 1; pila.pop(); while (nodos[pila.top()].apu == 2) { lli act = pila.top(); pila.pop(); lli izq = nodos[act].h[0]; lli der = nodos[act].h[1]; nodos[act].tam = nodos[izq].tam + nodos[der].tam; lli a,b,c,d; a = nodos[izq].res; b = nodos[izq].tam - nodos[izq].res + 1; if (nodos[izq].tipo == 2) swap(a,b); c = nodos[der].res; d = nodos[der].tam - nodos[der].res + 1; if (nodos[der].tipo == 2) swap(c,d); if (nodos[act].tipo == 1) nodos[act].res = a+c-1; else nodos[act].res = b+d-1; pos++; } cont++; pos += 2; } cout << nodos[1].res; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:36:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     while (pos < st.size()) {
      |            ~~~~^~~~~~~~~~~
#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...