QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140070 | #4400. Homework | scidroid | 0 | 25ms | 3472kb | C++17 | 1.6kb | 2023-08-15 02:42:03 | 2023-08-15 02:42:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pb push_back
ll check(string a, vll p) {
ll val1 = -1;
ll val2 = -1;
ll res = 0;
ll res2 = 0;
ll counter = p.size() - 1;
for (ll i = a.size() - 1; i >= 0; i--) {
if (a[i] == '?') {
if (val1 == -1) {
val1 = p[counter];
counter--;
} else {
val2 = p[counter];
counter--;
}
} else {
if (a[i] == 'n') {
if (val2 == -1 && val1 == -1) {
res = min(res, res2);
} else if (val2 == -1) {
res2 = res;
res = min(res, val1);
} else {
res = min(val1, val2);
}
} else {
if (val2 == -1 && val1 == -1) {
res = max(res, res2);
} else if (val2 == -1) {
res2 = res;
res = max(res, val1);
} else {
res = max(val1, val2);
}
}
val1 = -1;
val2 = -1;
}
}
return res;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
string a; cin >> a;
string r;
ll counter = 0;
for (ll i = 0; i < a.size(); i++) {
if (a[i] == 'n') {
r.pb('n');
}
if (a[i] == 'x') {
r.pb('x');
}
if (a[i] == '?') {
r.pb('?');
counter++;
}
}
ll qsss = 0;
for (ll i = r.size() - 1; i >= 0; i--) {
if (r[i] == '?') {
qsss++;
if (qsss == 3) {
r[i] = r[i - 1];
r[i - 1] = '?';
}
} else {
qsss = 0;
}
}
vll vals;
set<ll> res;
for (ll i = 1; i <= counter; i++){
vals.pb(i);
}
do {
res.insert(check(r, vals));
} while(next_permutation(vals.begin(), vals.end()));
cout << res.size() << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 25ms
memory: 3472kb
input:
min(max(?,max(min(?,min(?,?)),?)),min(max(?,?),max(?,?)))
output:
8
result:
wrong answer 1st lines differ - expected: '6', found: '8'
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%