Task: | Lista |
Sender: | MojoLake |
Submission time: | 2022-01-22 15:05:57 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | TIME LIMIT EXCEEDED | 0 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
#4 | WRONG ANSWER | 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 | WRONG ANSWER | 0.01 s | 3 | details |
#9 | TIME LIMIT EXCEEDED | -- | 3 | details |
#10 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:25:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(s.length()<prevlen){ ~~~~~~~~~~^~~~~~~~ input/code.cpp:29:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] else if(s.length()>prevlen){ ~~~~~~~~~~^~~~~~~~ input/code.cpp:31:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < s.length(); ++i){ ~~^~~~~~~~~~~~ input/code.cpp:42:25: warning: unused variable 'x' [-Wunused-variable] int x = c - '0'; ^ input/code.cpp:57:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < s.length(); ++i){ ~~^~~~~~~~~~~~ input/code.cpp:101:25: warning: comparison between signed and uns...
Code
#include <bits/stdc++.h>#define ll long long#define mp make_pair#define pb push_back#define F first#define S secondusing namespace std;const int N = (int)1e5;const ll inf = (ll)1e18;vector<string> ans;int main(){ios_base::sync_with_stdio(0); cin.tie(0);int n; cin >> n;ll prevlen = 0;string prevstring = "";while(n--){string s; cin >> s;if(s.length()<prevlen){cout << "IMPOSSIBLE\n";return 0;}else if(s.length()>prevlen){string new_s = "";for(int i = 0; i < s.length(); ++i){char c = s[i];if(c=='?'){if(!i){new_s+="1";}else{new_s+="0";}}else{int x = c - '0';new_s += string(1, c);}}prevlen = new_s.length();prevstring = new_s;ans.pb(prevstring);}else{bool tight = 1;ll new_prev = 0;string new_s = "";for(int i = 0; i < s.length(); ++i){char c = s[i];if(c!='?'){int prev_x = prevstring[i] - '0';int x = c - '0';if(tight){if(prev_x>x){cout << "IMPOSSIBLE\n";return 0;}else if(prev_x<x){tight = 0;new_s+=string(1, c);}else{new_s+=string(1, c);}}else if(!tight){new_s += string(1, c);}}else if(c=='?'){if(!tight){if(i==0){new_s+="1";}else{new_s+="0";}}else if(tight){if(i==s.length()-1){if(prevstring[i]=='9'){cout << "IMPOSSIBLE\n";return 0;}char new_c = prevstring[i];int add = new_c - '0';add++;//cout << "newwccwew: " << new_c << " " << add << "\n";new_s += to_string(add);continue;}//we want to check the next element whether it is finebool putequal = 1;for(int k = i+1; k < s.length(); ++i){if(s[k]=='?'&&prevstring[k]!='9')break;else if(s[k]=='?'&&prevstring[k]=='9'&& k!= s.length()-1)continue;else if(s[k]=='?'&&prevstring[k]=='9' && k == s.length()-1){putequal=0;break;}int cur = s[k] - '0';int pr = prevstring[k] - '0';if(cur>pr)break;else if(cur==pr)continue;putequal = 0;break;}if(putequal){char newc = prevstring[i];int add = newc - '0';new_s += string(1, newc);}else{tight = 0;if(prevstring[i]=='9'){cout << "IMPOSSIBLE\n";return 0;}int newc = prevstring[i];int add = newc - '0';add++;newc = char(add);new_s += string(1, newc);}}}}prevstring = new_s;prevlen = new_s.length();ans.pb(prevstring);}}for(auto x : ans){cout << x << "\n";}return 0;}
Test details
Test 1
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 ?? ?? ?? ?? ... |
correct output |
---|
10 11 12 13 20 ... |
user output |
---|
(empty) |
Test 2
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 8?? ??8? ???? ???? ... |
correct output |
---|
800 1080 1081 1082 1083 ... |
user output |
---|
(empty) |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 ?????? ?????9? ??98??? ?????5? ... |
correct output |
---|
100000 1000090 1098000 1098050 4100001 ... |
user output |
---|
(empty) |
Test 4
Group: 1, 2, 3
Verdict: WRONG ANSWER
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 124 |
Test 7
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
5 1?? ??? 2?? ??? ... |
correct output |
---|
IMPOSSIBLE |
user output |
---|
IMPOSSIBLE |
Test 8
Group: 3
Verdict: WRONG ANSWER
input |
---|
1000 ????????? ????????? ????????? ????????? ... |
correct output |
---|
100000000 100000001 100000002 100000003 100000004 ... |
user output |
---|
100000000 100000001 100000002 100000003 100000004 ... Truncated |
Test 9
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
900 ???000000 ???000000 ???000000 ???000000 ... |
correct output |
---|
100000000 101000000 102000000 103000000 104000000 ... |
user output |
---|
(empty) |
Test 10
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 ???1????? ???0????? ???1????? ???0????? ... |
correct output |
---|
100100000 101000000 101100000 102000000 102100000 ... |
user output |
---|
(empty) |