Submission #1226195

#TimeUsernameProblemLanguageResultExecution timeMemory
1226195trideserHomework (CEOI22_homework)C++20
13 / 100
163 ms104000 KiB
#include <bits/stdc++.h> using namespace std; int rec(string& s, int& index, vector<tuple<char, int, int>>& ops) { //cerr << "REC: " << index << "\n"; for(int i = index; i < s.size(); i++) { //cerr << s[i]; } //cerr << "\n"; char op = s[index + 2]; int lchild; int rchild; index += 4; //cerr << "\t" << s[index] << "\n"; if(s[index] == 'm') { lchild = rec(s, index, ops); } else { lchild = -1; index++; } index++; //cerr << "\t" << s[index] << "\n"; if(s[index] == 'm') { rchild = rec(s, index, ops); } else { rchild = -1; index++; } index++; //cerr << "\n\n"; ops.push_back(make_tuple(op, lchild, rchild)); return ops.size() - 1; } int get_size(vector<tuple<char, int, int>>& ops, int node, char ch) { if(node == -1 || get<0>(ops[node]) != ch) { return 0; } return 1 + get_size(ops, get<1>(ops[node]), ch) + get_size(ops, get<2>(ops[node]), ch); } int main() { string input; cin >> input; //cerr << input << "\n"; vector<tuple<char, int, int>> ops; int ix = 0; rec(input, ix, ops); //cerr << "OPS:\n\n"; for(tuple<char, int, int> t : ops) { //cerr << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << "\n"; } cout << ops.size() + 1 - get_size(ops, ops.size() - 1, 'x') - get_size(ops, ops.size() - 1, 'n'); return 0; }
#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...