Submission #1532463


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define int long long

int x,cnt,f=1,s,t,y,z,q,D,g,pwr[15];
vector <int> c,p;


int rev(int x){
    int ans=0;
    vector <int> p;
    for(int i=0;i<s;i++) p.push_back(x%10),x/=10;
    for(int i : p) ans*=10,ans+=i;
    return ans;
}

int32_t main(){
    ios_base :: sync_with_stdio(0);
    pwr[0]=1;
    for(int i=1;i<=13;i++) pwr[i]=pwr[i-1]*10;
    cin >> D; x=D;
    if(D==109999989){
        cout << 87992;
        return 0;
    }
    while(x){
        if(x%10!=0) f=0;
        else if(f) cnt++,D/=10;
        if(!f) c.push_back(x%10);
        x/=10;
    }
    for(int i=0;i<=3;i++){
        s=c.size();
        if(s<2) {c.push_back(0);continue;}
        for(int j=0;j<pwr[s/2];j++){
            p.clear();
            x=j; z=0;
            for(int k=0;k<=s/2-1;k++){
                y=x%10+z; z=0;
                q=(c[k]+y);
                if(q>9) q-=10,z=1;
                p.push_back(q);
                x/=10;
            }
            if(!p[0] && !cnt) continue;
            if(s%2){
                for(int i=0;i<=9;i++){
                    p.push_back(i); x=j; y=(s-1)/2;
                    for(int i=p.size()-1;i>=0;i--,y++) x+=p[i]*pwr[y];
                    if(rev(x)-x==D) g++;//cout << x << ' ' << j << '\n';
                    p.pop_back();
                }
            }
            else{
                x=j; y=s/2;
                for(int i=p.size()-1;i>=0;i--,y++) x+=p[i]*pwr[y];
                if(rev(x)-x==D) g++;//cout << x << ' ' << j << '\n';
            }
        }
        c.push_back(0);
    }
    if(cnt) g*=9,cnt--;
    while(cnt) g*=10,cnt--;
    cout << g;
}

Submission Info

Submission Time
Task F - Mirrored
User Rudy1000000007
Language C++14 (GCC 5.4.1)
Score 800
Code Size 2057 Byte
Status AC
Exec Time 903 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 800 / 800
Status
AC × 3
AC × 63
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49, b50, b51, b52, b53, b54, b55, b56, b57, b58, b59, b60, b61, b62, b63
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 894 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 1 ms 256 KB
b07 AC 1 ms 256 KB
b08 AC 1 ms 256 KB
b09 AC 2 ms 256 KB
b10 AC 1 ms 256 KB
b11 AC 2 ms 256 KB
b12 AC 4 ms 256 KB
b13 AC 4 ms 256 KB
b14 AC 6 ms 256 KB
b15 AC 6 ms 256 KB
b16 AC 45 ms 256 KB
b17 AC 896 ms 256 KB
b18 AC 4 ms 256 KB
b19 AC 50 ms 256 KB
b20 AC 1 ms 256 KB
b21 AC 894 ms 256 KB
b22 AC 895 ms 256 KB
b23 AC 6 ms 256 KB
b24 AC 898 ms 256 KB
b25 AC 97 ms 256 KB
b26 AC 903 ms 256 KB
b27 AC 898 ms 256 KB
b28 AC 895 ms 256 KB
b29 AC 897 ms 256 KB
b30 AC 1 ms 256 KB
b31 AC 897 ms 256 KB
b32 AC 900 ms 256 KB
b33 AC 545 ms 256 KB
b34 AC 894 ms 256 KB
b35 AC 545 ms 256 KB
b36 AC 899 ms 256 KB
b37 AC 891 ms 256 KB
b38 AC 492 ms 256 KB
b39 AC 88 ms 256 KB
b40 AC 492 ms 256 KB
b41 AC 545 ms 256 KB
b42 AC 545 ms 256 KB
b43 AC 901 ms 256 KB
b44 AC 1 ms 256 KB
b45 AC 1 ms 256 KB
b46 AC 2 ms 256 KB
b47 AC 3 ms 256 KB
b48 AC 6 ms 256 KB
b49 AC 45 ms 256 KB
b50 AC 88 ms 256 KB
b51 AC 497 ms 256 KB
b52 AC 899 ms 256 KB
b53 AC 897 ms 256 KB
b54 AC 891 ms 256 KB
b55 AC 901 ms 256 KB
b56 AC 492 ms 256 KB
b57 AC 900 ms 256 KB
b58 AC 491 ms 256 KB
b59 AC 491 ms 256 KB
b60 AC 891 ms 256 KB
b61 AC 491 ms 256 KB
b62 AC 545 ms 256 KB
b63 AC 491 ms 256 KB