QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#344336 | #8251. Missing Number | Haidy_Yasser# | WA | 148ms | 3880kb | C++14 | 2.5kb | 2024-03-04 03:03:36 | 2024-03-04 03:03:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) int(x.size())
#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define cin(v) for (auto& cn : v) cin >> cn;
#define cout(v) for (auto &cn : v) cout << cn << " ";
#define MOD int(1e9+7)
// #define endl "\n"
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
void Haidy()
{
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
//freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#endif
}
void solve();
int main()
{
Haidy();
int t = 1;
cin >> t;
for(int i = 1;i<=t; i++)
{
solve();
}
return 0;
}
// int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
// int dy[] = {1, -1, 0, 0, 1, -1, -1, 1};
bool allNine(string s)
{
for(auto &c : s)
if(c != '9')
return false;
return true;
}
void solve()
{
string s;
cin >> s;
int n = sz(s);
for(int len = 1; len <= 5; len++){
int l = len;
bool ok = true;
int prev = 0, cnt = 0, missing = 0, cnt2 = 0;
for(int i = 0; i < n; i += l){
if(allNine(to_string(prev)))
l++;
if(i + l <= n){
string sub = s.substr(i, l);
while(sub[0] == '0' && l+1 <= 5 && l + 1 <= n){
sub = s.substr(i, l+1);
l++;
}
if(!prev)
prev = stoi(sub);
else{
int cur = stoi(sub);
while((cur < prev || sub[0] == '0') && l+1 <= 5 && l + 1 <= n){
sub = s.substr(i, l+1);
l++;
}
cur = stoi(sub);
if(cur-prev > 1){
cnt++;
cnt2 = cur - prev - 1;
missing = prev + 1;
}
if(cnt > 1 || cur - prev <= 0 || sub[0] == '0')
ok = false;
prev = cur;
}
}
else{
// cout << i << " " << l << "\n" ;
ok = false;
break;
}
}
if(ok && cnt <= 1){
cout << cnt2 << endl;
for(int i = 0; i < cnt2; i++){
cout << missing+i << " ";
}
return;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3880kb
input:
1 891112
output:
1 10
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 148ms
memory: 3592kb
input:
31408 787187871978720787217872278723787247872678727 8787287874878758787687877 834918349283493834958349683497 295982959929600296012960229604 602160226023602460256027602860296030 504545045550456504575045850459504605046250463 17937179381794017941 5226152262522635226552266 304693047030471304733047430475...
output:
1 78725 1 87873 1 83494 1 29603 1 6026 1 50461 1 17939 1 52264 1 30472 1 71484 1 44832 1 88042 1 75634 1 63756 1 65055 1 66515 1 26238 1 29009 1 45270 1 11194 1 75204 1 74784 1 72747 1 29546 1 81791 1 11504 1 73091 1 15640 1 36200 1 47814 1 82261 1 3667 1 6949 1 81711 1 32272 1 74387 1 40400 1 76903...
result:
wrong answer 2nd lines differ - expected: '78725', found: '78725 1'