| Task: | Lista |
| Sender: | intoo |
| Submission time: | 2022-01-22 14:48:37 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
| #2 | WRONG ANSWER | 0.01 s | 2, 3 | details |
| #3 | WRONG ANSWER | 0.01 s | 3 | details |
| #4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #5 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #6 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
| #7 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #8 | ACCEPTED | 0.01 s | 3 | details |
| #9 | WRONG ANSWER | 0.01 s | 3 | details |
| #10 | ACCEPTED | 0.01 s | 3 | details |
Code
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ll = long long;
string fill_blanks(string s, string l)
{
int n = s.size();
if (l.empty()) {
if (s[0] == '?') s[0] = '1';
for (int i = 1; i < n; ++i)
if (s[i] == '?') s[i] = '0';
return s;
}
if (l.size() > s.size()) return "";
if (l.size() < s.size()) {
if (s[0] == '?') s[0] = '1';
for (int i = 1; i < n; ++i)
if (s[i] == '?') s[i] = '0';
if (stoi(s) <= stoi(l)) return "";
return s;
}
int nines = 0;
for (int i = 0; i < n; ++i)
nines += l[i] == '9';
if (nines == n) return "";
if (nines == n-1 && l[0] != '9') {
if (s[0] == '?')
s[0] = l[0] + 1;
else if (s[0] <= l[0])
return "";
}
vector<int> b(n);
for (int i = 0; i < n; ++i) {
if (s[i] == l[i] || s[i] == '?')
b[i] = 0;
else
b[i] = (s[i]-l[i])/abs(s[i]-l[i]);
}
vector<int> qi;
for (int i = 0; i < n; ++i) {
if (s[i] == '?')
qi.push_back(i);
}
int le = 0, gr = 0;
while (le <= n && b[le] != -1) ++le;
while (gr <= n && b[gr] != 1) ++gr;
if (gr < le) {
for (int i : qi) {
if (i < gr) s[i] = l[i];
else s[i] = '0';
}
} else if (le < gr) {
int ti = -1;
for (int i : qi)
if (i < le && l[i] != '9') ti = i;
if (ti == -1) return "";
for (int i : qi) {
if (i < ti) s[i] = l[i];
else if (i == ti) s[i] = l[i]+1;
else s[i] = '0';
}
} else { // only question marks
s = to_string(stoi(l)+1);
}
if (stoi(s) <= stoi(l)) return "";
return s;
// int qs = 0;
// for (int i = 0; i < n; ++i)
// qs += s[i] == '?';
// bool g = 0;
// for (int i = 0; i < n; ++i) {
// if (s[i] != '?') {
// g |= s[i] > l[i];
// continue;
// }
// s[i] = §
// if (qs == 1) {
// if (g) continue;
// }
// --qs;
// }
}
int main()
{
//ios_base::sync_with_stdio(false);
//cin.tie(nullptr);
int n;
cin >> n;
vector<string> v(n);
string l;
for (int i = 0; i < n; ++i) {
string s;
cin >> s;
s = fill_blanks(s, l);
if (s.empty()) {
cout << "IMPOSSIBLE" << endl;
return 0;
}
v[i] = s;
l = s;
}
for (string s : v)
cout << s << endl;
}
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 100 ?? ?? ?? ?? ... |
| correct output |
|---|
| 10 11 12 13 20 ... |
| user output |
|---|
| 10 11 12 13 20 ... Truncated |
Test 2
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000 8?? ??8? ???? ???? ... |
| correct output |
|---|
| 800 1080 1081 1082 1083 ... |
| user output |
|---|
| 800 1080 1081 1082 1083 ... Truncated |
Test 3
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000 ?????? ?????9? ??98??? ?????5? ... |
| correct output |
|---|
| 100000 1000090 1098000 1098050 4100001 ... |
| user output |
|---|
| 100000 1000090 1098000 1098050 4100001 ... Truncated |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 ? ? ? ? ... |
| correct output |
|---|
| 1 2 3 4 5 ... |
| user output |
|---|
| 1 2 3 4 5 ... Truncated |
Test 5
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 2 ??? ?? |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| IMPOSSIBLE |
Test 6
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 3 123 ??? 124 |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| 123 124 125 |
Test 7
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 5 1?? ??? 2?? ??? ... |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| IMPOSSIBLE |
Test 8
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 1000 ????????? ????????? ????????? ????????? ... |
| correct output |
|---|
| 100000000 100000001 100000002 100000003 100000004 ... |
| user output |
|---|
| 100000000 100000001 100000002 100000003 100000004 ... Truncated |
Test 9
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 900 ???000000 ???000000 ???000000 ???000000 ... |
| correct output |
|---|
| 100000000 101000000 102000000 103000000 104000000 ... |
| user output |
|---|
| 100000000 100000001 101000000 101000001 102000000 ... Truncated |
Test 10
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 1000 ???1????? ???0????? ???1????? ???0????? ... |
| correct output |
|---|
| 100100000 101000000 101100000 102000000 102100000 ... |
| user output |
|---|
| 100100000 101000000 101100000 102000000 102100000 ... Truncated |
