CSES - Datatähti 2022 loppu - Results
Submission details
Task:Lista
Sender:andreibe
Submission time:2022-01-22 16:42:42 +0200
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 s1, 2, 3details
#20.01 s2, 3details
#30.01 s3details
#4ACCEPTED0.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.01 s1, 2, 3details
#7ACCEPTED0.01 s1, 2, 3details
#8ACCEPTED0.01 s3details
#9ACCEPTED0.01 s3details
#100.01 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:57:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < s.length(); j++)
                   ~~^~~~~~~~~~~~
input/code.cpp:31:6: warning: unused variable 'lastNum' [-Wunused-variable]
  int lastNum = 0;
      ^~~~~~~

Code

#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <algorithm>
#include <vector>
#include <fstream>
#include <set>
#include <unordered_map>
#include <queue>
#include <climits>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define LOOP(i,a,l) for (int i = a; i < l; i++)
#define LUO_VERKKO LOOP(i,0,m) {int a,b; cin >> a >> b; v[a].push_back(b); v[b].push_back(a);}
#define COLLECT for (int i = 0; i < n; i++) cin >> s[i]
#define PRINT_LIST(l) for (int i = 0; i < l.size(); i++) cout << l[i] << " "
#define S second
#define F first
#define A 999999999999999999LL
#define M 1000000007
//https://cses.fi/dt/
int n;
int t;
pair<int, int> d[11][11][5];
#define N (1<<17)
int main() {
cin >> n;
int lastNum = 0;
vector<string> v;
vector<string> t;
for (int i = 0; i < n; i++)
{
string s; cin >> s;
t.push_back(s);
}
string last = t[t.size() - 1];
replace(last.begin(), last.end(), '?', '9');
v.push_back(last);
for (int i = t.size()-2; i >= 0; i--)
{
bool done = false;
string s = t[i];
string org = s;
if (s.length() < last.length()) {
replace(s.begin(), s.end(), '?', '9');
v.push_back(s);
last = s;
continue;
}
if (s.length() > last.length()) {
cout << "IMPOSSIBLE";
exit(0);
}
for (int j = 0; j < s.length(); j++)
{
if (s[j] == '?') {
s[j] = last[j];
continue;
}
string ch = string(1, last[j]);
string ch2 = string(1, s[j]);
if (stoi(ch2) < stoi(ch)) {
replace(s.begin(), s.end(), '?', '9');
v.push_back(s);
done = true;
break;
}
else if (stoi(ch2) > stoi(ch)){
cout << "IMPOSSIBLE";
exit(0);
}
}
if (done) {
last = s;
continue;
}
for (int j = s.length()-1; j >= 0; j--)
{
string ch = string(1, last[j]);
if (last[j] != '0' && org[j] == '?') {
s[j] = to_string(stoi(ch) - 1)[0];
break;
}
if (last[j] == '0' && org[j] == '?') {
int index = j;
while (index >= 0 && s[index] == '0') {
if (org[index] != '?') {
cout << "IMPOSSIBLE";
exit(0);
}
s[index] = '9';
index--;
}
if (index != -1) {
if (org[index] != '?') {
cout << "IMPOSSIBLE";
exit(0);
}
string ch2 = string(1, s[index]);
s[index] = to_string(stoi(ch2) - 1)[0];
}
break;
}
}
if (stoi(s) < stoi(last) && s[0] != '0') {
v.push_back(s);
}
else {
cout << "IMPOSSIBLE";
exit(0);
}
last = s;
}
for (int i = v.size()-1; i >= 0; i--)
{
cout << v[i] << "\n";
}
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
100
??
??
??
??
...

correct output
10
11
12
13
20
...

user output
IMPOSSIBLE

Test 2

Group: 2, 3

Verdict:

input
1000
8??
??8?
????
????
...

correct output
800
1080
1081
1082
1083
...

user output
IMPOSSIBLE

Test 3

Group: 3

Verdict:

input
1000
??????
?????9?
??98???
?????5?
...

correct output
100000
1000090
1098000
1098050
4100001
...

user output
IMPOSSIBLE

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: ACCEPTED

input
3
123
???
124

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

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: ACCEPTED

input
900
???000000
???000000
???000000
???000000
...

correct output
100000000
101000000
102000000
103000000
104000000
...

user output
100000000
101000000
102000000
103000000
104000000
...
Truncated

Test 10

Group: 3

Verdict:

input
1000
???1?????
???0?????
???1?????
???0?????
...

correct output
100100000
101000000
101100000
102000000
102100000
...

user output
IMPOSSIBLE