QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#650942 | #7529. Form Processing | ucup-team3519# | WA | 0ms | 3880kb | C++17 | 2.2kb | 2024-10-18 17:10:41 | 2024-10-18 17:10:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define V vector
#define pb push_back
typedef long long LL;
void solve() {
string s; cin >> s;
V<V<V<int>>> minus_element;
int type1 = 1;// + -
int type2 = 1;// * /
V<V<int>> cur;
auto restore = [&]() -> void {
if(type1 == 1) return;
minus_element.pb(cur);
cur.clear();
};
for(int i = 0; i < s.size(); i++) {
if(s[i] == '-' || s[i] == '+') {
restore();
type1 = 0;
}
if(type1 == 0) {
assert(s[i] == '-' || s[i] == '+');
if(s[i] == '-') type1 = 2;
else type1 = 1;
type2 = 1;
} else if(type2 == 0) {
assert(s[i] == '*' || s[i] == '/');
if(s[i] == '*') type2 = 1;
else type2 = 2;
} else {
if(type2 == 1) {
if(type1 == 1) s[i] = '9';
else s[i] = '1';
} else {
if(type1 == 1) s[i] = '1';
else {
if(cur.size() <= 5) cur.pb({i});
else s[i] = '1';
}
}
type2 = 0;
}
}
restore();
map<int, V<V<V<int>>>> mp;
for(auto v : minus_element) {
mp[v.size()].pb(v);
}
auto upd = [&](V<V<V<int>>> v) -> V<V<int>> {
assert(v.size() <= 9);
int aim = v.size();
for(auto &t : v) {
for(auto x : t.back()) {
s[x] = '0' + aim;
}
t.pop_back();
}
V<V<int>> ans;
for(int i = 0; i < v.back().size(); i++) {
V<int> cur;
for(auto t : v) {
for(auto x : t[i]) cur.pb(x);
}
ans.pb(cur);
}
return ans;
};
for(int i = 5; i >= 1; i--) {
while(mp[i].size()) {
V<V<V<int>>> now;
while(mp[i].size() && now.size() < 9) {
now.pb(mp[i].back());
mp[i].pop_back();
}
mp[i - 1].pb(upd(now));
}
}
cout << s << endl;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
?*?+?/?-?
output:
9*9+9/1-1
result:
ok OK!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
?
output:
9
result:
ok OK!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
?-?/?-?/?
output:
9-1/2-1/2
result:
ok OK!
Test #4:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
?-?/?/?/?-?/?+?/?*?
output:
9-1/2/1/1-1/2+9/1*9
result:
ok OK!
Test #5:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
?*?-?+?/?+?*?+?+?-?*?+?-?/?+?/?/?-?/?+?+?*?-?*?*?-?/?/?/?/?/?*?+?+?*?-?*?/?*?/?+?-?-?/?/?*?+?/?-?+?*?*?*?-?*?/?*?-?
output:
9*9-1+9/1+9*9+9+9-1*1+9-1/4+9/1/1-1/4+9+9*9-1*1*1-1/4/3/1/1/1*1+9+9*9-1*1/4*1/3+9-1-1/4/3*1+9/1-1+9*9*9*9-1*1/4*1-1
result:
ok OK!
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3824kb
input:
?-?/?-?-?-?/?-?-?/?-?/?/?-?-?-?/?/?/?/?-?-?/?/?/?/?/?/?/?-?/?-?-?-?/?/?-?-?-?-?-?/?/?/?/?-?/?/?-?/?-?-?/?/?/?-?-?-?/?-?-?/?-?/?/?/?-?/?/?-?-?/?-?/?/?-?-?-?-?/?-?/?/?-?-?/?/?/?-?-?/?/?/?-?/?-?/?/?/?/?/?
output:
9-1/2-1-1-1/2-1-1/9-1/9/7-1-1-1/9/7/5/3-1-1/?/?/?/?/?/?/1-1/9-1-1-1/9/7-1-1-1-1-1/9/7/5/3-1/9/7-1/9-1-1/9/7/5-1-1-1/9-1-1/9-1/9/7/5-1/9/7-1-1/9-1/9/7-1-1-1-1/9-1/9/7-1-1/9/7/5-1-1/9/7/5-1/9-1/9/7/5/3/1
result:
wrong answer Token parameter [name=answer] equals to "9-1/2-1-1-1/2-1-1/9-1/9/7-1-1-...9/7/5-1-1/9/7/5-1/9-1/9/7/5/3/1", doesn't correspond to pattern "[1-9+*/-]{201,201}"