Submission #1521454


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<=1;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) {c.push_back(0);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 2001 Byte
Status RE
Exec Time 2104 ms
Memory 5996 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 2
RE × 1
AC × 23
WA × 5
TLE × 5
RE × 30
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 RE 123 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 WA 1 ms 256 KB
b09 AC 1 ms 256 KB
b10 AC 1 ms 256 KB
b11 WA 1 ms 256 KB
b12 TLE 2103 ms 1020 KB
b13 AC 1 ms 256 KB
b14 TLE 2104 ms 5740 KB
b15 TLE 2103 ms 5996 KB
b16 WA 1 ms 256 KB
b17 RE 123 ms 256 KB
b18 AC 1 ms 256 KB
b19 WA 3 ms 256 KB
b20 RE 123 ms 256 KB
b21 RE 123 ms 256 KB
b22 RE 123 ms 256 KB
b23 AC 2 ms 256 KB
b24 RE 123 ms 256 KB
b25 AC 5 ms 256 KB
b26 RE 123 ms 256 KB
b27 RE 124 ms 256 KB
b28 RE 123 ms 256 KB
b29 RE 123 ms 256 KB
b30 AC 1 ms 256 KB
b31 RE 122 ms 256 KB
b32 RE 123 ms 256 KB
b33 AC 47 ms 256 KB
b34 RE 123 ms 256 KB
b35 AC 47 ms 256 KB
b36 RE 123 ms 256 KB
b37 RE 123 ms 256 KB
b38 RE 98 ms 256 KB
b39 WA 3 ms 256 KB
b40 RE 99 ms 256 KB
b41 AC 47 ms 256 KB
b42 AC 50 ms 256 KB
b43 RE 123 ms 256 KB
b44 AC 1 ms 256 KB
b45 AC 1 ms 256 KB
b46 AC 1 ms 256 KB
b47 TLE 2103 ms 892 KB
b48 TLE 2103 ms 4716 KB
b49 AC 1 ms 256 KB
b50 AC 3 ms 256 KB
b51 RE 98 ms 256 KB
b52 RE 123 ms 256 KB
b53 RE 124 ms 256 KB
b54 RE 122 ms 256 KB
b55 RE 123 ms 256 KB
b56 RE 98 ms 256 KB
b57 RE 124 ms 256 KB
b58 RE 98 ms 256 KB
b59 RE 99 ms 256 KB
b60 RE 124 ms 256 KB
b61 RE 98 ms 256 KB
b62 AC 49 ms 256 KB
b63 RE 98 ms 256 KB