CSES - Datatähti 2022 loppu - Results
Submission details
Task:Lista
Sender:MojoLake
Submission time:2022-08-25 13:43:27 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 s1, 2, 3details
#20.01 s2, 3details
#30.01 s3details
#40.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#60.01 s1, 2, 3details
#7ACCEPTED0.01 s1, 2, 3details
#80.01 s3details
#90.01 s3details
#100.01 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i < first.length(); ++i){
                    ~~^~~~~~~~~~~~~~~~
input/code.cpp:47:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(pre.length() > cl){
            ~~~~~~~~~~~~~^~~~
input/code.cpp:51:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(cl > pre.length()){
            ~~~^~~~~~~~~~~~~~
input/code.cpp:36:14: warning: unused variable 'lz' [-Wunused-variable]
         bool lz = 1;
              ^~

Code

#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ll = long long;
void gg(){
cout << "IMPOSSIBLE\n";
exit(0);
}
int dig_at_pos(int num, int pos){
while(pos--)num/=10;
return num%10;
}
int main(){
int n;
cin >> n;
vector<string> a(n);
for(auto& x : a){
cin >> x;
}
string first = a[0];
if(first[0] == '?')first[0] = '1';
for(int i = 1; i < first.length(); ++i){
if(first[i] == '?')first[i] = '0';
}
//cout << first << "\n";
a[0] = first;
for(int k = 1; k < n; ++k){
bool lz = 1;
bool tight = 1;
string pre = a[k-1];
string cur = a[k];
string now = "";
//cout << pre << " " << cur << "\n";
int cl = cur.length();
//cout << cl << "\n";
if(pre.length() > cl){
//cout << "kek\n" << pre << "\n";
gg();
}
if(cl > pre.length()){
for(int i = 0; i < cl; ++i){
if(cur[i] == '?')now += '0' + (i == 0);
else now += cur[i];
}
}
else{
for(int i = 0; i < cl; ++i){
//cout << now << "\n";
if(pre[i] == cur[i])now+=cur[i];
else if(pre[i] > cur[i] && cur[i] != '?' && tight){
//cout << "hah\n";
gg();
}
else if(cur[i] > pre[i] && cur[i] != '?')tight = 0, now+=cur[i];
else if(cur[i]=='?'){
if(!tight){
now += ('0' + (i == 0));
}
else{
bool ok = 0;
for(int j = i + 1; j < cl; ++j){
if(cur[j] > pre[j]){
ok = 1;
break;
}
if(cur[j] == '?'){
if(pre[j] == '9')continue;
ok = 1;
break;
}
break;
}
if(!ok && pre[i] == '9'){
gg();
}
else{
if(ok)now += pre[i];
else{
//cout << "hah\n";
now += pre[i] + 1;
tight = 0;
}
}
}
}
}
}
//cout << now << "\n";
a[k] = now;
}
for(int i = 0; i < n; ++i){
cout << a[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:

input
100
?
?
?
?
...

correct output
1
2
3
4
5
...

user output
IMPOSSIBLE

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
2
???
??

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 6

Group: 1, 2, 3

Verdict:

input
3
123
???
124

correct output
IMPOSSIBLE

user output
123
124
124

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

input
5
1??
???
2??
???
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 8

Group: 3

Verdict:

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

correct output
100000000
100000001
100000002
100000003
100000004
...

user output
IMPOSSIBLE

Test 9

Group: 3

Verdict:

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

correct output
100000000
101000000
102000000
103000000
104000000
...

user output
IMPOSSIBLE

Test 10

Group: 3

Verdict:

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

correct output
100100000
101000000
101100000
102000000
102100000
...

user output
100100000
10100000
100100000
10100000
100100000
...
Truncated