답안 #754542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754542 2023-06-08T02:56:30 Z drdilyor Homework (CEOI22_homework) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#ifdef ONPC
    #include "t_debug.cpp"
#else
    #define debug(...) 42
#endif
using namespace std;
//namespace pbds = __gnu_pbds;
using ll = long long;
const int inf = 1e9;
const ll infl = 1e18;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; }
template<typename Cont> int sz(const Cont& cont) { return int(cont.size()); }
template<typename Func> struct ycom { Func f; template<typename... T> auto operator()(T&&... args) { return f(*this, args...); } }; template<typename Func> ycom(Func) -> ycom<Func>;
template<typename T> typename vector<T>::iterator operator+(const vector<T>& x, int i) { return x.begin() + i ;};
const string fileio = "";
constexpr int tests = 0, nmax = 2e5, nlog = __lg(nmax), mod = 1e9+7;

int TQ = 0, TMIN = 1, TMAX = 2;
struct node {
    int type;
    node* l=nullptr; node* r=nullptr;
    void print() {
        if (type == TQ) cout << "?";
        else {
            if (type == TMIN) cout << "min(";
            else cout << "max(";
            l->print();
            cout << ",";
            r->print();
            cout << ")";
        }
    }
};

node* parse(string& s, int& i) {
    if (s[i++] == '?') return new node{TQ};
    auto res = new node;
    if (s[i++] == 'i') {
        res->type = TMIN;
    } else res->type = TMAX;
    i++;
    assert(s[i++] == '(');
    res->l = parse(s, i);
    assert(s[i++] == ',');
    res->r = parse(s, i);
    assert(s[i++] == ')');
    return res;
}

int solve() {
    string s;
    cin >> s;
    int i = 0;
    auto root = parse(s, i);
#ifdef ONPC
    root->print();
#endif
    int cnt=  0;
    int t = root->type;
    while (root) {
        if (root->type == t) {
            root = root->l->type == TQ ? root->r : root->l;
            cnt++;
        } else break;
    }
    cout << n - cnt << '\n';
    return 0;
}

signed main() {
    int t = 1;
    #ifdef ONPC
    t = 10000;
    #else
    if (fileio.size()) {freopen((fileio+".in").c_str(),"r",stdin);freopen((fileio+".out").c_str(),"w",stdout);}
    #endif
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit | cin.eofbit);
    cout << fixed << setprecision(12);
    if (tests) cin >> t;
    while (t-- && cin) {
        if (solve()) break;
        #ifdef ONPC
            cout << "____________________" << endl;
        #endif
    }
    return 0;
}

/*
     █████               █████  ███  ████                               
    ▒▒███               ▒▒███  ▒▒▒  ▒▒███                               
  ███████  ████████   ███████  ████  ▒███  █████ ████  ██████  ████████ 
 ███▒▒███ ▒▒███▒▒███ ███▒▒███ ▒▒███  ▒███ ▒▒███ ▒███  ███▒▒███▒▒███▒▒███
▒███ ▒███  ▒███ ▒▒▒ ▒███ ▒███  ▒███  ▒███  ▒███ ▒███ ▒███ ▒███ ▒███ ▒▒▒ 
▒███ ▒███  ▒███     ▒███ ▒███  ▒███  ▒███  ▒███ ▒███ ▒███ ▒███ ▒███     
▒▒████████ █████    ▒▒████████ █████ █████ ▒▒███████ ▒▒██████  █████    
 ▒▒▒▒▒▒▒▒ ▒▒▒▒▒      ▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒   ▒▒▒▒▒███  ▒▒▒▒▒▒  ▒▒▒▒▒     
                                            ███ ▒███                    
                                           ▒▒██████                     
                                            ▒▒▒▒▒▒
*/

Compilation message

Main.cpp: In function 'int solve()':
Main.cpp:69:13: error: 'n' was not declared in this scope
   69 |     cout << n - cnt << '\n';
      |             ^
Main.cpp: In function 'int main()':
Main.cpp:78:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |     if (fileio.size()) {freopen((fileio+".in").c_str(),"r",stdin);freopen((fileio+".out").c_str(),"w",stdout);}
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:78:74: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |     if (fileio.size()) {freopen((fileio+".in").c_str(),"r",stdin);freopen((fileio+".out").c_str(),"w",stdout);}
      |                                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~