CSES - Datatähti 2022 loppu - Results
Submission details
Task:Lista
Sender:Anniiiz
Submission time:2022-01-22 15:32:35 +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
#40.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.01 s1, 2, 3details
#70.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:24:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int j = 0; j < s.size(); j++) {
                     ~~^~~~~~~~~~
input/code.cpp:32:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (k[i-1] == s.size()) {
             ~~~~~~~^~~~~~~~~~~
input/code.cpp:50:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     else if (!a || s.size() < k[i-1]) {
                    ~~~~~~~~~^~~~~~~~
input/code.cpp:54:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (s.size() == k[i-1]) {
         ~~~~~~~~~^~~~~~~~~
input/code.cpp:57:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for (int j = 0; j < s.size(); ++j) {
                       ~~^~~~~~~~~~
input/code.cpp:85:29: warning: comparison between signed and u...

Code

#include <iostream>
#include <vector>
#include<algorithm>
#include <map>
using namespace std;
using ll = long long;
vector<ll> lista;
int t[10001][10];
int k[1001];
vector<string> alku;

int main() {
  ll n;
  string s;
  cin >> n;
  ll f = 0;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    alku.push_back(s);
    ll a = 0;
    ll suurempi = 0;
    ll pienempi = 0;
    k[i] = s.size();
    for (int j = 0; j < s.size(); j++) {
      //cout << "xd" << endl;
      if (s[j] == '?') {
        a++;
        t[i][j] = 10;
      }
      else {
        t[i][j] = s[j]-'0';
        if (k[i-1] == s.size()) {
          if (t[i-1][j] > t[i][j]) {
            if (!pienempi && !suurempi) {
              suurempi = j;
            }
          }
          else {
            pienempi++;
          }
        }
      }
    }
    //cout << "toimiiko" << endl;
    if (!a && (i == 0 || stoi(s) > lista.back())) {
      //cout << "lol" << endl;
      lista.push_back(stoi(s));
      continue;
    }
    else if (!a || s.size() < k[i-1]) {
      f++;
      break;
    }
    if (s.size() == k[i-1]) {
      //cout << "täällä" << endl;
      string e = "";
      for (int j = 0; j < s.size(); ++j) {
        //cout << e << endl;
        if (t[i][j] == 10) {
          e += to_string(t[i-1][j]);
          t[i][j] = t[i-1][j];
        }
        else {
          e += to_string(t[i][j]);
        }
      }
      //cout << e << endl;
      if (suurempi) {
        ll l = 0;
        ll kohta = 10;
        for (int j = suurempi-1; j >= 0; j--) {
          if (alku[i][j] == '?' && t[i][j] != 9) {
            l++;
            kohta = j;
            break;
          }
        }
        if (!l) {
          f++;
          break;
        }
        else {
          t[i][kohta]++;
          e = "";
          for (int j = 0; j < s.size(); ++j) {
            e += to_string(t[i][j]);
          }
        }
      }
      if (stoi(e) <= lista.back()) {
        //cout << "melkeen ongelma" << endl;
        ll l = 0;
        ll kohta = 10;
        for (int j = s.size()-1; j >= 0; j--) {
          //cout << alku[i][j] << " " << t[i][j] << endl;
          if (alku[i][j] == '?' && t[i][j] != 9) {
            l++;
            kohta = j;
            break;
          }
        }
        //cout << kohta << " " << t[i][kohta] << endl;
        if (!l) {
          f++;
          break;
        }
        else {
          t[i][kohta]++;
          e = "";
          for (int j = 0; j < s.size(); ++j) {
            //cout << e << endl;
            e += to_string(t[i][j]);
          }
          //cout << e << endl;
        }
      }
      lista.push_back(stoi(e));
    }
    else if (s.size() > k[i-1]) {
      string e = "";
      for (int j = 0; j < s.size(); ++j) {
        if (t[i][j] == 10) {
          if (j == 0) {
            e += '1';
            t[i][j] = 1;
          }
          else {
            t[i][j] = 0;
            e += '0';
          }
        }
        else e += to_string(t[i][j]);
      }
      lista.push_back(stoi(e));
    }
  }
  if (f) cout << "IMPOSSIBLE" << endl;
  else {
    for (auto u : lista) {
      cout << u << endl;
    }
  }
}

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

input
3
123
???
124

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 7

Group: 1, 2, 3

Verdict:

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

correct output
IMPOSSIBLE

user output
100
101
201
202
103

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
IMPOSSIBLE