답안 #1036866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036866 2024-07-27T18:10:42 Z vjudge1 Homework (CEOI22_homework) C++17
10 / 100
1000 ms 45332 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sort undefined_function // To use stable_sort instead sort 
#define bpc __builtin_popcount
#define ull unsigned long long
#define ld double
#define ll long long
#define mp make_pair
#define F first
#define S second

#pragma GCC optimize("O3")

#ifdef LOCAL 
        #include "debug.h"
#else 
        #define dbg(...) 0
#endif

using namespace __gnu_pbds;
using namespace std;

typedef tree<long long, null_type, less_equal<long long>,
    rb_tree_tag, tree_order_statistics_node_update> Tree;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll INF = 9223372036854775807LL;
const ll inf = 2147483647;
const ll MOD = 998244353; //[998244353, 1e9 + 7, 1e9 + 13]
const ld PI = acos(-1);
const ll NROOT = 800;

ll binpow(ll a, ll b, ll _MOD = -1) {
        if (_MOD == -1)
                _MOD = MOD;
        ll res = 1;
        for (; b; b /= 2, a *= a, a %= _MOD)
                if (b & 1) res *= a, res %= _MOD;
        return res;
}

void set_IO(string s) {
#ifndef LOCAL
        string in  = s +  ".in";
        string out = s + ".out";
        freopen(in.c_str(),  "r",  stdin);
        freopen(out.c_str(), "w", stdout);
#endif
}

bool dataOverflow(ll a, ll b) {return (log10(a) + log10(b) >= 18);}
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
ll ceil(ll a, ll b) {return (a + b - 1) / b;}
ll invmod(ll a) {return binpow(a, MOD - 2);}

string s;
vector<int> p, v;

int calc(int l, int r) {
        if (s[l] == 'm') {
                int comma = -1, cnt = 0;
                for (int i = l + 4; i < r; i ++) {
                        if (s[i] == ',' && cnt == 0) {
                                comma = i;
                                break;
                        } 
                        if (s[i] == '(') 
                                cnt ++;
                        if (s[i] == ')')
                                cnt --;
                } 

                if (s[l + 1] == 'i') { // MIN
                        return min(calc(l + 4, comma - 1), calc(comma + 1, r - 1));
                } else { // MAX 
                        return max(calc(l + 4, comma - 1), calc(comma + 1, r - 1));
                }
        } else { // ? 
                return v[p[l]];
        }
}

int32_t main() {
        ios_base::sync_with_stdio(0);
        cin.tie(0);

        cin >> s;
        p.resize(s.size(), -1);
        int n = 0;

        for (int i = 0; i < s.size(); i ++) {
                if (s[i] == '?') {
                        p[i] = n;
                        n ++;
                }
        }

        v.resize(n);
        for (int i = 0; i < n; i ++)
                v[i] = i + 1;

        set<int> ans;
        do {
                ans.insert(calc(0, s.size() - 1));
        } while (next_permutation(v.begin(), v.end()));

        cout << ans.size() << "\n";
        dbg(ans);

        return 0;
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:93:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |         for (int i = 0; i < s.size(); i ++) {
      |                         ~~^~~~~~~~~~
Main.cpp:18:26: warning: statement has no effect [-Wunused-value]
   18 |         #define dbg(...) 0
      |                          ^
Main.cpp:110:9: note: in expansion of macro 'dbg'
  110 |         dbg(ans);
      |         ^~~
Main.cpp: In function 'void set_IO(std::string)':
Main.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         freopen(in.c_str(),  "r",  stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen(out.c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 432 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Correct 37 ms 348 KB Output is correct
4 Correct 39 ms 348 KB Output is correct
5 Correct 37 ms 344 KB Output is correct
6 Correct 46 ms 348 KB Output is correct
7 Correct 41 ms 440 KB Output is correct
8 Correct 54 ms 436 KB Output is correct
9 Correct 38 ms 344 KB Output is correct
10 Correct 49 ms 348 KB Output is correct
11 Correct 32 ms 348 KB Output is correct
12 Correct 40 ms 344 KB Output is correct
13 Correct 35 ms 348 KB Output is correct
14 Correct 40 ms 344 KB Output is correct
15 Correct 39 ms 344 KB Output is correct
16 Correct 55 ms 348 KB Output is correct
17 Correct 42 ms 348 KB Output is correct
18 Correct 55 ms 432 KB Output is correct
19 Correct 60 ms 436 KB Output is correct
20 Correct 73 ms 344 KB Output is correct
21 Correct 49 ms 348 KB Output is correct
22 Correct 44 ms 344 KB Output is correct
23 Correct 41 ms 348 KB Output is correct
24 Correct 46 ms 348 KB Output is correct
25 Correct 4 ms 344 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 432 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Correct 37 ms 348 KB Output is correct
4 Correct 39 ms 348 KB Output is correct
5 Correct 37 ms 344 KB Output is correct
6 Correct 46 ms 348 KB Output is correct
7 Correct 41 ms 440 KB Output is correct
8 Correct 54 ms 436 KB Output is correct
9 Correct 38 ms 344 KB Output is correct
10 Correct 49 ms 348 KB Output is correct
11 Correct 32 ms 348 KB Output is correct
12 Correct 40 ms 344 KB Output is correct
13 Correct 35 ms 348 KB Output is correct
14 Correct 40 ms 344 KB Output is correct
15 Correct 39 ms 344 KB Output is correct
16 Correct 55 ms 348 KB Output is correct
17 Correct 42 ms 348 KB Output is correct
18 Correct 55 ms 432 KB Output is correct
19 Correct 60 ms 436 KB Output is correct
20 Correct 73 ms 344 KB Output is correct
21 Correct 49 ms 348 KB Output is correct
22 Correct 44 ms 344 KB Output is correct
23 Correct 41 ms 348 KB Output is correct
24 Correct 46 ms 348 KB Output is correct
25 Correct 4 ms 344 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Execution timed out 1092 ms 348 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1090 ms 45332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 432 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Correct 37 ms 348 KB Output is correct
4 Correct 39 ms 348 KB Output is correct
5 Correct 37 ms 344 KB Output is correct
6 Correct 46 ms 348 KB Output is correct
7 Correct 41 ms 440 KB Output is correct
8 Correct 54 ms 436 KB Output is correct
9 Correct 38 ms 344 KB Output is correct
10 Correct 49 ms 348 KB Output is correct
11 Correct 32 ms 348 KB Output is correct
12 Correct 40 ms 344 KB Output is correct
13 Correct 35 ms 348 KB Output is correct
14 Correct 40 ms 344 KB Output is correct
15 Correct 39 ms 344 KB Output is correct
16 Correct 55 ms 348 KB Output is correct
17 Correct 42 ms 348 KB Output is correct
18 Correct 55 ms 432 KB Output is correct
19 Correct 60 ms 436 KB Output is correct
20 Correct 73 ms 344 KB Output is correct
21 Correct 49 ms 348 KB Output is correct
22 Correct 44 ms 344 KB Output is correct
23 Correct 41 ms 348 KB Output is correct
24 Correct 46 ms 348 KB Output is correct
25 Correct 4 ms 344 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Execution timed out 1092 ms 348 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 432 KB Output is correct
2 Correct 39 ms 348 KB Output is correct
3 Correct 37 ms 348 KB Output is correct
4 Correct 39 ms 348 KB Output is correct
5 Correct 37 ms 344 KB Output is correct
6 Correct 46 ms 348 KB Output is correct
7 Correct 41 ms 440 KB Output is correct
8 Correct 54 ms 436 KB Output is correct
9 Correct 38 ms 344 KB Output is correct
10 Correct 49 ms 348 KB Output is correct
11 Correct 32 ms 348 KB Output is correct
12 Correct 40 ms 344 KB Output is correct
13 Correct 35 ms 348 KB Output is correct
14 Correct 40 ms 344 KB Output is correct
15 Correct 39 ms 344 KB Output is correct
16 Correct 55 ms 348 KB Output is correct
17 Correct 42 ms 348 KB Output is correct
18 Correct 55 ms 432 KB Output is correct
19 Correct 60 ms 436 KB Output is correct
20 Correct 73 ms 344 KB Output is correct
21 Correct 49 ms 348 KB Output is correct
22 Correct 44 ms 344 KB Output is correct
23 Correct 41 ms 348 KB Output is correct
24 Correct 46 ms 348 KB Output is correct
25 Correct 4 ms 344 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Execution timed out 1092 ms 348 KB Time limit exceeded
30 Halted 0 ms 0 KB -