Task: | Greater Integers |
Sender: | aryan12 |
Submission time: | 2021-01-30 21:43:48 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 2 | details |
Compiler report
input/code.cpp: In function 'void Solve()': input/code.cpp:16:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < s.size(); i++) { ~~^~~~~~~~~~ input/code.cpp:21:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(cnt_nine == s.size()) { ~~~~~~~~~^~~~~~~~~~~ input/code.cpp:22:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i <= s.size(); i++) { ~~^~~~~~~~~~~ input/code.cpp:35:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 1; i < s.size(); i++) { ~~^~~~~~~~~~ input/code.cpp:45:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < s.size(); i++) { ~~^~~~~~~~~~ input/code.cpp:34:6: warning: unused variable 'cur' [-Wunused-variable] int cur = s...
Code
#include <bits/stdc++.h> using namespace std; #define int long long void PrintAns(int num, int siz) { for(int i = 0; i < siz; i++) { cout << num; } cout << "\n"; } void Solve() { string s; cin >> s; int cnt_nine = 0; for(int i = 0; i < s.size(); i++) { if(s[i] == '9') { cnt_nine++; } } if(cnt_nine == s.size()) { for(int i = 0; i <= s.size(); i++) { cout << "1"; } cout << "\n"; return; } if(s.size() == 1) { int x = s[0] - '0' + 1; cout << x << "\n"; return; } bool edge = true; int cur = s[0] - '0'; for(int i = 1; i < s.size(); i++) { if(edge && s[i] > s[0]) { s[0]++; PrintAns(s[0] - '0', s.size()); return; } else if(s[i] < s[0]) { edge = false; } } for(int i = 0; i < s.size(); i++) { cout << s[0]; } cout << "\n"; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; cin >> t; while(t--) { Solve(); } }
Test details
Test 1
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
1000 1 2 3 4 ... |
correct output |
---|
2 3 4 5 6 ... |
user output |
---|
2 3 4 5 6 ... Truncated |
Test 2
Group: 2
Verdict: ACCEPTED
input |
---|
1000 735425311146082632 756615631808964686 466489470801941584 100417544394053220 ... |
correct output |
---|
777777777777777777 777777777777777777 555555555555555555 111111111111111111 555555555555555555 ... |
user output |
---|
777777777777777777 777777777777777777 555555555555555555 111111111111111111 55555555555555 ... Truncated |