QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#134575#4400. HomeworkJoshi503#10 41ms3856kbC++174.6kb2023-08-04 00:44:582024-07-04 01:15:59

Judging History

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

  • [2024-07-04 01:15:59]
  • 评测
  • 测评结果:10
  • 用时:41ms
  • 内存:3856kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-04 00:44:58]
  • 提交

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 op, cur, prev;
};

void solve(){

    str s; cin >> s;
    int n = 0;
    each(x, s){
        n += (x == '?');
    }
    str mini = "min(?,?)", maxi = "max(?,?)", t = s;
    vector<Opt> v;
    while(1){
        str tmp = "";
        F0R(i, sz(t)){
            if(t[i] == '?') v.pb({2, sz(tmp), i});
            if(i + 7){
                str x = t.substr(i, 8);
                if(x == mini || x == maxi){
                    // cout << (x == mini) << " " << i + 4 << "\n";
                    v.pb({x == maxi, sz(tmp), i + 4});
                    tmp += '?';
                    i += 7;
                }
                else tmp += t[i];
            }
            else tmp += t[i];
        }
        // cout << tmp << "\n";
        t = tmp;
        if(t == "?") break;
    }    

    vi a(n);
    iota(all(a), 1);
    // a = {1, 3, 2, 4, 5};
    vb res(n + 1, 0);
    do{

        vi c(sz(s), 0);
        int cnt = 0;
        F0R(i, sz(s)){
            if(s[i] == '?') c[i] = a[cnt++];
        }
        // each(x, c) cout << x << " ";
        // cout << "\n";
        each(x, v){
            // cout << x.op << " " << c[x.prev] << " " << c[x.prev + 2] << " " << x.cur << " " << x.prev << "\n";
            if(x.op == 1){
                c[x.cur] = max(c[x.prev], c[x.prev + 2]);
            }
            else if(x.op == 0){
                // cout << c[x.prev] << " " << c[x.prev + 2] << "\n";
                c[x.cur] = min(c[x.prev], c[x.prev + 2]);
            }
            else{
                c[x.cur] = c[x.prev];
            }
            // cout << c[x.cur] << "\n";
            // each(x, c) cout << x << " ";
            // cout << "\n";
        }
        if(!res[c[0]]){
            // cout << c[0] << "\n";
            // each(x, a) cout << x << " ";
            // cout << "\n";
        }
        res[c[0]] = 1;

    } while(next_permutation(all(a)));

    int ans = 0;
    FOR(i, 1, n + 1) ans += res[i];
    cout << ans << "\n";
}

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

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 29ms
memory: 3848kb

input:

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

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 29ms
memory: 3616kb

input:

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

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 25ms
memory: 3568kb

input:

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

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 27ms
memory: 3848kb

input:

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

output:

3

result:

ok single line: '3'

Test #5:

score: 0
Accepted
time: 29ms
memory: 3652kb

input:

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

output:

6

result:

ok single line: '6'

Test #6:

score: 0
Accepted
time: 24ms
memory: 3680kb

input:

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

output:

4

result:

ok single line: '4'

Test #7:

score: 0
Accepted
time: 29ms
memory: 3820kb

input:

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

output:

6

result:

ok single line: '6'

Test #8:

score: 0
Accepted
time: 27ms
memory: 3624kb

input:

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

output:

2

result:

ok single line: '2'

Test #9:

score: 0
Accepted
time: 27ms
memory: 3816kb

input:

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

output:

1

result:

ok single line: '1'

Test #10:

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

input:

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

output:

7

result:

ok single line: '7'

Test #11:

score: 0
Accepted
time: 30ms
memory: 3616kb

input:

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

output:

7

result:

ok single line: '7'

Test #12:

score: 0
Accepted
time: 29ms
memory: 3516kb

input:

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

output:

7

result:

ok single line: '7'

Test #13:

score: 0
Accepted
time: 32ms
memory: 3568kb

input:

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

output:

2

result:

ok single line: '2'

Test #14:

score: 0
Accepted
time: 29ms
memory: 3552kb

input:

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

output:

7

result:

ok single line: '7'

Test #15:

score: 0
Accepted
time: 31ms
memory: 3856kb

input:

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

output:

7

result:

ok single line: '7'

Test #16:

score: 0
Accepted
time: 39ms
memory: 3696kb

input:

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

output:

7

result:

ok single line: '7'

Test #17:

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

input:

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

output:

7

result:

ok single line: '7'

Test #18:

score: 0
Accepted
time: 39ms
memory: 3624kb

input:

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

output:

1

result:

ok single line: '1'

Test #19:

score: 0
Accepted
time: 38ms
memory: 3624kb

input:

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

output:

1

result:

ok single line: '1'

Test #20:

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

input:

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

output:

8

result:

ok single line: '8'

Test #21:

score: 0
Accepted
time: 32ms
memory: 3624kb

input:

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

output:

1

result:

ok single line: '1'

Test #22:

score: 0
Accepted
time: 27ms
memory: 3692kb

input:

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

output:

1

result:

ok single line: '1'

Test #23:

score: 0
Accepted
time: 30ms
memory: 3592kb

input:

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

output:

5

result:

ok single line: '5'

Test #24:

score: 0
Accepted
time: 26ms
memory: 3552kb

input:

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

output:

6

result:

ok single line: '6'

Test #25:

score: 0
Accepted
time: 3ms
memory: 3856kb

input:

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

output:

2

result:

ok single line: '2'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

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

output:

1

result:

ok single line: '1'

Test #27:

score: 0
Accepted
time: 3ms
memory: 3616kb

input:

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

output:

4

result:

ok single line: '4'

Test #28:

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

input:

max(?,?)

output:

1

result:

ok single line: '1'

Subtask #2:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Test #29:

score: 0
Time Limit Exceeded

input:

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

output:


result:


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:

100%
Accepted

Dependency #2:

0%