Submission #486786

# Submission time Handle Problem Language Result Execution time Memory
486786 2021-11-12T19:34:27 Z NintsiChkhaidze Palindrome-Free Numbers (BOI13_numbers) C++14
56.6667 / 100
1000 ms 324 KB
#include <bits/stdc++.h>
#define pb push_back
#define s second
#define f first
#define ll long long
#define int ll
using namespace std;

int p[25];
signed main (){
    ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
    
    p[0] = 1;
    for (int i = 1; i <= 18; i++)
        p[i] = p[i - 1]*10;
        
    int a,b,ans=0;
    cin>>a>>b;

    for (int i = a; i <= b; ){
        int q=1,cnt=0,x=0;
        for (int j = 18; j >= 0; j--){
            if (i < p[j]) continue;
            cnt++;
            int y = (i/p[j])%10;
            x = x*10 + y;
            // if (i== 199)
                // cout<<cnt<<" "<<y<<" "<<p[j]<<" "<<p[j + 1]<<" "<<p[j + 2]<<endl;
                
            if ((cnt > 1 && y == (i/p[j + 1])%10) || (cnt > 2 && y == (i/p[j + 2])%10)){
                // cout<<"num = "<<i<<" "<<cnt<<" "<<j<<endl;
                q=0;
                x++;
                x *= p[j];
                // cout<<"num = "<<i<<" "<<x<<endl;
                // exit(0);
                break;
            }
            
        }
        
        if (q) ans++,i++;
        else i = x;
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 19 ms 204 KB Output is correct
4 Correct 5 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 5 ms 204 KB Output is correct
15 Correct 5 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 2 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 19 ms 312 KB Output is correct
20 Correct 5 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 370 ms 288 KB Output is correct
2 Execution timed out 1093 ms 204 KB Time limit exceeded
3 Execution timed out 1093 ms 204 KB Time limit exceeded
4 Execution timed out 1084 ms 204 KB Time limit exceeded
5 Execution timed out 1091 ms 204 KB Time limit exceeded
6 Execution timed out 1085 ms 204 KB Time limit exceeded
7 Correct 145 ms 204 KB Output is correct
8 Correct 104 ms 292 KB Output is correct
9 Correct 186 ms 292 KB Output is correct
10 Correct 264 ms 324 KB Output is correct
11 Correct 380 ms 292 KB Output is correct
12 Execution timed out 1086 ms 204 KB Time limit exceeded
13 Correct 416 ms 292 KB Output is correct
14 Execution timed out 1076 ms 204 KB Time limit exceeded
15 Execution timed out 1077 ms 204 KB Time limit exceeded
16 Execution timed out 1070 ms 204 KB Time limit exceeded
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Execution timed out 1089 ms 204 KB Time limit exceeded
22 Correct 0 ms 204 KB Output is correct
23 Execution timed out 1089 ms 204 KB Time limit exceeded
24 Correct 0 ms 204 KB Output is correct
25 Execution timed out 1088 ms 204 KB Time limit exceeded
26 Execution timed out 1091 ms 204 KB Time limit exceeded
27 Execution timed out 1093 ms 204 KB Time limit exceeded
28 Execution timed out 1086 ms 204 KB Time limit exceeded
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Execution timed out 1088 ms 204 KB Time limit exceeded
32 Correct 0 ms 204 KB Output is correct
33 Execution timed out 1092 ms 204 KB Time limit exceeded
34 Correct 0 ms 204 KB Output is correct
35 Execution timed out 1093 ms 204 KB Time limit exceeded
36 Execution timed out 1096 ms 204 KB Time limit exceeded
37 Execution timed out 1095 ms 204 KB Time limit exceeded
38 Execution timed out 1091 ms 204 KB Time limit exceeded
39 Execution timed out 1093 ms 204 KB Time limit exceeded
40 Correct 0 ms 312 KB Output is correct
41 Execution timed out 1089 ms 204 KB Time limit exceeded
42 Correct 0 ms 204 KB Output is correct
43 Execution timed out 1081 ms 204 KB Time limit exceeded
44 Execution timed out 1089 ms 204 KB Time limit exceeded
45 Execution timed out 1085 ms 204 KB Time limit exceeded