QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#613604#8249. Lines Per HoureggtoastWA 0ms3716kbC++171.8kb2024-10-05 14:18:582024-10-05 14:20:30

Judging History

你现在查看的是最新测评结果

  • [2024-10-05 14:20:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3716kb
  • [2024-10-05 14:18:58]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int main() {
    int t;
    cin >> t;
    while(t--) {
        string s;
        cin >> s;
        int n = s.size() / 2;

        unsigned long long flg = 0;
        unsigned long long start = 0;
        while(n >= 1) {
            string sub = s.substr(0, n);
            string other = s.substr(n, n);

            unsigned long long x1 = stoull(sub);
            unsigned long long x2 = stoull(other);

            if((x2 == x1 + 1) || (x2 == x1 + 2)) {
                if(x2 == x1 + 1) {
                    flg = 1; // we know the starting point, so we look for the missing number
                    start = x1;
                } else {
                    flg = 2; // case where 2nd number is missing
                    start = x1;
                }
                break;
            } 
            n--;
        }

        // if flg == 0, no missing numbers
        if(flg == 0) {
            cout << 0 << '\n';
            continue;
        } else if (flg == 1) {
            // we loop from start to end to find the missing number.
            unsigned long long curr = start;
            while(!s.empty()) {
                int digitsLeft = log10(curr) + 1;

                if(stoull(s.substr(0, digitsLeft)) != curr) {
                    cout << 1 << '\n';
                    cout << curr << '\n';
                    break;
                }

                s.erase(0, digitsLeft);
                curr++;
            }

            // if string is empty that means no missing numbers either
            if(s.empty())
                cout << 0 << '\n';

        } else if (flg == 2) {
            cout << 1 << '\n';
            cout << start + 1 << '\n';
            continue;
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3716kb

input:

10 100
30
300
1000
20
35
19
84
117
212
98

output:

0
0
0
0
0
1
4
0
0
0
0

result:

wrong answer 1st lines differ - expected: '7', found: '0'