Submission #1687971


Source Code Expand

///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
ll f[20][2][2];// [l,mid] +10 [mid+1,r] -1
int bit[20],len;
int get(int x) {return x<0?x+10:x;}
int main() {
	int d=read(),t=d;
	while(t) bit[++len]=t%10,t/=10;
	ll res=0;
	for(int l=2;l<=18;l+=2) {
		memset(f,0,sizeof(f));
		f[0][0][0]=1;
		rep(x,1,9) rep(y,0,9) {
			if(y-x<bit[l]) continue;
			if(y-x>bit[l]+1) continue;
			if(get(x-y)!=bit[1]) continue;
			f[1][(y-x)==bit[l]?0:1][x-y<0?1:0]++;
		}
		rep(i,1,l/2-2) rep(x,0,1) rep(y,0,1) {
			ll& ans=f[i][x][y];if(!ans) continue;
			rep(px,0,9) rep(py,0,9) {
				int cx=py-px+x*10,cy=px-py-y;
				if(cx<bit[l-i]) continue;
				if(cx>bit[l-i]+1) continue;
				if(get(cy)!=bit[i+1]) continue;
				f[i+1][cx==bit[l-i]?0:1][cy<0?1:0]+=ans;
			}
		}
		rep(x,0,1) rep(y,0,1) {
			ll& ans=f[l/2-1][x][y];if(!ans) continue;
			rep(px,l>2?0:1,9) rep(py,0,9) {
				int cx=py-px+x*10,cy=px-py-y;
				if(cy<0) cx--,cy+=10;
				if(cx==bit[l/2+1]&&cy==bit[l/2]) res+=ans;
			}
		}
	}
	for(int l=3;l<=19;l+=2) {
		memset(f,0,sizeof(f));
		f[0][0][0]=1;
		rep(x,1,9) rep(y,0,9) {
			if(y-x<bit[l]) continue;
			if(y-x>bit[l]+1) continue;
			if(get(x-y)!=bit[1]) continue;
			f[1][(y-x)==bit[l]?0:1][x-y<0?1:0]++;
		}
		rep(i,1,l/2-1) rep(x,0,1) rep(y,0,1) {
			ll& ans=f[i][x][y];if(!ans) continue;
			rep(px,0,9) rep(py,0,9) {
				int cx=py-px+x*10,cy=px-py-y;
				if(cx<bit[l-i]) continue;
				if(cx>bit[l-i]+1) continue;
				if(get(cy)!=bit[i+1]) continue;
				f[i+1][cx==bit[l-i]?0:1][cy<0?1:0]+=ans;
			}
		}
		rep(x,0,1) rep(y,0,1) {
			ll& ans=f[l/2][x][y];if(!ans) continue;
			rep(px,0,9) {
				int cx=x*10-y;
				if(cx==bit[l/2+1]) res+=ans;
			}
		}
	}
	printf("%lld\n",res);
	return 0;
}

Submission Info

Submission Time
Task F - Mirrored
User wzj52501
Language C++14 (GCC 5.4.1)
Score 0
Code Size 4195 Byte
Status WA
Exec Time 1 ms
Memory 128 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 3
AC × 54
WA × 9
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 128 KB
a02 AC 1 ms 128 KB
a03 AC 0 ms 128 KB
b04 AC 0 ms 128 KB
b05 AC 1 ms 128 KB
b06 AC 1 ms 128 KB
b07 AC 0 ms 128 KB
b08 AC 0 ms 128 KB
b09 AC 0 ms 128 KB
b10 AC 1 ms 128 KB
b11 AC 1 ms 128 KB
b12 AC 0 ms 128 KB
b13 AC 1 ms 128 KB
b14 AC 1 ms 128 KB
b15 AC 1 ms 128 KB
b16 AC 1 ms 128 KB
b17 AC 1 ms 128 KB
b18 WA 1 ms 128 KB
b19 WA 0 ms 128 KB
b20 AC 1 ms 128 KB
b21 AC 1 ms 128 KB
b22 AC 1 ms 128 KB
b23 WA 1 ms 128 KB
b24 AC 1 ms 128 KB
b25 WA 1 ms 128 KB
b26 AC 1 ms 128 KB
b27 AC 1 ms 128 KB
b28 AC 0 ms 128 KB
b29 AC 0 ms 128 KB
b30 WA 0 ms 128 KB
b31 WA 0 ms 128 KB
b32 WA 1 ms 128 KB
b33 AC 1 ms 128 KB
b34 WA 0 ms 128 KB
b35 AC 1 ms 128 KB
b36 AC 1 ms 128 KB
b37 AC 1 ms 128 KB
b38 AC 0 ms 128 KB
b39 AC 1 ms 128 KB
b40 AC 0 ms 128 KB
b41 AC 1 ms 128 KB
b42 AC 1 ms 128 KB
b43 AC 0 ms 128 KB
b44 AC 0 ms 128 KB
b45 AC 1 ms 128 KB
b46 AC 1 ms 128 KB
b47 AC 1 ms 128 KB
b48 AC 1 ms 128 KB
b49 AC 1 ms 128 KB
b50 AC 1 ms 128 KB
b51 WA 0 ms 128 KB
b52 AC 0 ms 128 KB
b53 AC 0 ms 128 KB
b54 AC 1 ms 128 KB
b55 AC 1 ms 128 KB
b56 AC 1 ms 128 KB
b57 AC 1 ms 128 KB
b58 AC 1 ms 128 KB
b59 AC 0 ms 128 KB
b60 AC 0 ms 128 KB
b61 AC 0 ms 128 KB
b62 AC 1 ms 128 KB
b63 AC 0 ms 128 KB