QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#344333 | #8251. Missing Number | Haidy_Yasser# | WA | 149ms | 3604kb | C++14 | 2.2kb | 2024-03-04 02:40:57 | 2024-03-04 02:40:57 |
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(prev && allNine(to_string(prev)))
l++;
if(i + l <= n){
string sub = s.substr(i, l);
// cout << sub << " ";
if(!prev)
prev = stoi(sub);
else{
int cur = stoi(sub);
if(cur-prev == 0){
ok = false;
break;
}
if(cur-prev > 1){
cnt++;
cnt2 = cur - prev - 1;
missing = prev + 1;
}
prev = cur;
if(cnt > 1){
ok = false;
break;
}
}
}
else{
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: 3604kb
input:
1 891112
output:
1 10
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 149ms
memory: 3544kb
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 597 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 ...
result:
wrong answer 2nd lines differ - expected: '78725', found: '78725 1'