CSES - Datatähti 2022 loppu - Results
Submission details
Task:Lista
Sender:hltk
Submission time:2022-01-22 13:52:10 +0200
Language: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:22:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (cn > p.size()) {
         ~~~^~~~~~~~~~

Code

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s[n];
  for (auto &x : s) {
    cin >> x;
  }
  for (int i = 0; i < n - 1; ++i) {
    if (s[i].size() > s[i + 1].size()) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  }
  string p;
  for (int i = 0; i < n; ++i) {
    auto &c = s[i];
    int cn = (int) c.size();
    if (cn > p.size()) {
      if (c[0] == '?') {
        c[0] = '1';
      } else {
        for (int i = 1; i < cn; ++i) {
          if (c[i] == '?') {
            c[i] = '0';
          }
        }
      }
    } else {
      for (int i = 0; i < cn; ++i) {
        if (c[i] != '?') {
          continue;
        }
        bool f = 0;
        for (int j = i == 0; j <= 9; ++j) {
          c[i] = j + '0';
          auto t = c;
          for (int k = i + 1; k < cn; ++k) {
            if (t[k] == '?') {
              t[k] = '9';
            }
          }
          if (t > p) {
            f = 1;
            break;
          }
        }
        if (!f) {
          cout << "IMPOSSIBLE" << endl;
          return 0;
        }
      }
    }
    p = c;
  }
  for (auto &x : s) {
    cout << x << '\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
1????????
200000000
200000001
200000002
200000003
...

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
1??1?????
200000000
200100000
201000000
201100000
...