# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
791713 | enerelt14 | Homework (CEOI22_homework) | C++14 | 1042 ms | 14028 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
#define ff first
#define ss second
using namespace std;
string s;
pair<int, int> solve(int l, int r) {
if(l == r) return {0, 0};
int cnt = 0, x;
if(s[4 + l] != 'm') x = 5 + l;
else {
for(int i = 7 + l; i < r; i++) {
if(s[i] == '(') cnt++;
if(s[i] == ')') cnt--;
if(!cnt) {
x = i + 1;
break;
}
}
}
pair<int, int> a = solve(4 + l, x - 1), b = solve(x + 1, r - 1);
if(s[1 + l] == 'i') return {a.ff + b.ff + 1, min(a.ss, b.ss)};
else return {min(a.ff, b.ff), a.ss + b.ss + 1};
return {0, 0};
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);
cin >> s;
int n = (int)s.size() / 7 + 1;
pair<int, int> ans = solve(0, (int)s.size() - 1);
cout << n - ans.ff - ans.ss;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |