답안 #1083023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083023 2024-09-02T09:59:37 Z weakweakweak Homework (CEOI22_homework) C++17
0 / 100
190 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
#define fs first 
#define sc second

string s;
int meow = 0;
deque<int> dq[1010000];
pii f(int st, int ed, int lala) {
    if (st == ed) {
        meow++;
        return {0,0};
    }
    int complace = dq[lala+1].front(); 
    dq[lala+1].pop_front();
    pii p1 = f(st+4, complace-1, lala+1);
    pii p2 = f(complace+1, ed-1, lala+1);
    if (s[st + 1]=='a') return {p1.fs+p2.fs+1, min(p1.sc,p2.sc)};
    else return {min(p1.fs,p2.fs), p1.sc+p2.sc+1};
}

int main () {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> s;
    int now = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '(') now++;
        if (s[i] == ')') now--;
        if (s[i] == ',') dq[now].push_back(i);
    }
    pii p = f(0, s.size()-1, 0);
    cout << meow - p.fs - p.sc << '\n';
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (int i = 0; i < s.size(); i++) {
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 185 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 185 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 190 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 185 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 185 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -