QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#134603#4400. HomeworkJoshi503#0 0ms3620kbC++173.9kb2023-08-04 03:10:562024-07-04 01:16:25

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 01:16:25]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3620kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-04 03:10:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using db = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
#define f first
#define s second

#define tcT template<class T
#define tcTU tcT, class U
tcT> using V = vector<T>;
tcT, size_t SZ > using AR = array<T, SZ>;
using vi = V<int>;
using vb = V<bool>;
using vl = V<ll>;
using vd = V<db>;
using vs = V<str>;
using vpi = V<pi>;
using vpl = V<pl>;

#define sz(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend() 
#define sor(x) sort(all(x)) 
#define pb push_back
#define yes cout << "Y" << "e" << "s\n";
#define no cout << "N" << "o\n";

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = ((b)-1); i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rep(a) F0R(_,a)
#define each(a,x) for (auto& a: x)

const int MOD = 1e9+7;
const int MOD98 = 998244353;
const int MX = 1e9;
// const int INF = 1e18;
const db PI = acos((db)-1);
// const int dx[] = { 1,0,-1,0 };
// const int dy[] = { 0,1,0,-1 };
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if ((ll)(name.size())) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}
template<class T> bool ckmin(T& a, const T& b) {
    return b < a ? a = b, 1 : 0; 
} 
template<class T> bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0; 
}
void _print(char i) { cerr << i; }
void _print(string i) { cerr << i; }
void _print(float i) { cerr << i; }
void _print(int i) { cerr << i; }
void _print(double i) { cerr << i; }
void _print() { cerr << "\n"; };
template<typename x, typename y> void _print(pair<x, y>& t) { cerr << "{";_print(t.first);cerr << ", ";_print(t.second);cerr << "},"; }
template<typename x> void _print(x& t) { cerr << "{"; for (int i = 0;i < (int)t.size();i++) { _print(t[i]); if (i < (int)t.size() - 1) cerr << ", "; } cerr << "}"; }
template<typename x, typename... y> void _print(x a, y... b) { _print(a);if (sizeof...(b)) cerr << ", ";_print(b...); }
#define dbg(x...) cerr<<"["<<#x<<"] = [";_print(x);cerr<<"]\n";
int test;

/*


*/

struct Opt{
    int x, y;
    bool m;
};

void solve(){

    int n = 0;
    str s; cin >> s;
    
    each(x, s) n += (x == '?');
    vector<Opt> data(n - 1);
    vpi value(n);
    value[n - 1] = {1, n};
    int cnt = 0;
    F0R(i, sz(s)){
        if(s[i] == 'm'){
            data[cnt].m = (s[i + 1] == 'a');
            if(s[i + 4] == '?') data[cnt].x = n - 1;
            else data[cnt].x = cnt + 1;
            int j = i + 3, bC = 0, mC = 0;
            while(s[j] != ',' || bC != 0){
                j++;
                if(s[j] == 'a') mC++;
                if(s[j] == '(') bC++;
                else if(s[j] == ')') bC--;
            }
            if(s[j + 1] == '?') data[cnt].y = n - 1;
            else data[cnt].y = cnt + mC + 1;
            cnt++;
        }
    }

    for(int i = n - 2; i >= 0; i--){
        if(!data[i].m){
            value[i].f = min(value[data[i].x].f, value[data[i].y].f);
            value[i].s = value[data[i].x].s + value[data[i].y].s - (n + 1);
        }
        else{
            value[i].f = value[data[i].x].f + value[data[i].y].f;
            value[i].s = max(value[data[i].x].s, value[data[i].y].s);
        }
    }

    cout << value[0].s - value[0].f + 1 << "\n";

}

signed main() {
    setIO("");
    int T = 1;
    // cin >> T;
    for (test = 1; test <= T; test++) {
        // cout << "Case #" << test << ": " << a.f << " " << a.s << "\n";
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 0ms
memory: 3620kb

input:

min(max(?,max(min(?,min(?,?)),?)),min(max(?,?),max(?,?)))

output:

6

result:

ok single line: '6'

Test #2:

score: -10
Wrong Answer
time: 0ms
memory: 3620kb

input:

max(max(?,min(max(?,min(?,?)),?)),max(max(?,?),max(?,?)))

output:

6

result:

wrong answer 1st lines differ - expected: '4', found: '6'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Time Limit Exceeded

Test #57:

score: 0
Time Limit Exceeded

input:

min(?,min(?,min(min(min(min(?,min(min(?,min(?,min(?,min(min(?,min(?,min(min(?,min(min(?,min(?,min(?,min(min(?,min(min(?,min(min(?,min(?,min(?,min(min(?,min(min(?,min(min(min(min(?,min(min(min(min(min(?,min(min(?,min(min(?,min(?,min(?,min(?,min(min(?,min(?,min(?,min(?,min(min(?,min(?,min(?,min(min(mi...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%