Submission #1521654


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;
    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<=4;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 0
Code Size 1984 Byte
Status TLE
Exec Time 2103 ms
Memory 764 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 2
TLE × 1
AC × 41
TLE × 22
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 8 ms 764 KB
a02 AC 2 ms 256 KB
a03 TLE 2103 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 2 ms 256 KB
b07 AC 1 ms 256 KB
b08 AC 2 ms 256 KB
b09 AC 4 ms 256 KB
b10 AC 2 ms 256 KB
b11 AC 4 ms 256 KB
b12 AC 6 ms 256 KB
b13 AC 6 ms 256 KB
b14 AC 45 ms 256 KB
b15 AC 45 ms 256 KB
b16 AC 92 ms 256 KB
b17 TLE 2103 ms 256 KB
b18 AC 7 ms 256 KB
b19 AC 96 ms 256 KB
b20 TLE 2103 ms 256 KB
b21 TLE 2103 ms 256 KB
b22 TLE 2103 ms 256 KB
b23 AC 53 ms 256 KB
b24 TLE 2103 ms 256 KB
b25 AC 540 ms 256 KB
b26 TLE 2103 ms 256 KB
b27 TLE 2103 ms 256 KB
b28 TLE 2103 ms 256 KB
b29 TLE 2103 ms 256 KB
b30 AC 2 ms 256 KB
b31 TLE 2103 ms 256 KB
b32 TLE 2103 ms 256 KB
b33 AC 1034 ms 256 KB
b34 TLE 2103 ms 256 KB
b35 AC 1084 ms 256 KB
b36 TLE 2103 ms 256 KB
b37 TLE 2103 ms 256 KB
b38 AC 926 ms 256 KB
b39 AC 496 ms 256 KB
b40 AC 939 ms 256 KB
b41 AC 1019 ms 256 KB
b42 AC 1021 ms 256 KB
b43 TLE 2103 ms 256 KB
b44 AC 1 ms 256 KB
b45 AC 1 ms 256 KB
b46 AC 4 ms 256 KB
b47 AC 6 ms 256 KB
b48 AC 48 ms 256 KB
b49 AC 93 ms 256 KB
b50 AC 487 ms 256 KB
b51 AC 978 ms 256 KB
b52 TLE 2103 ms 256 KB
b53 TLE 2103 ms 256 KB
b54 TLE 2103 ms 256 KB
b55 TLE 2103 ms 256 KB
b56 AC 982 ms 256 KB
b57 TLE 2103 ms 256 KB
b58 AC 920 ms 256 KB
b59 AC 924 ms 256 KB
b60 TLE 2103 ms 256 KB
b61 AC 922 ms 256 KB
b62 AC 1016 ms 256 KB
b63 AC 922 ms 256 KB