Submission #3596249


Source Code Expand

#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 2005000
#define MOD 1000000007
#define N 200005
#define M 1000005
#define LOG 60
#define KOK 4000000
using namespace std;

int n;
ll ans,mul[20];
ll cur;
vector<int> d;

void eval(int to,bool flag) {

	ll add=1;

	for(int i=1;i<=to;i++) {

		int tot=0;

		for(int j=(i==1);j<=9;j++) {

			if(j-d[i-1]>=0 && j-d[i-1]<=9 && (!flag || i!=to || d[i-1]==0)) tot++;

		}

		add*=tot;

	}

	ans+=add;

}

void solve(int now,int to,bool flag) {

	if(now>to) {

		if(cur==-n) eval(to,flag);

		return ;

	}

	for(int i=-9;i<=9;i++) {

		d.pb(i);

		cur+=1ll*i*mul[now];

		solve(now+1,to,flag);

		cur-=1ll*i*mul[now];

		d.ppb();

	}

}

int main() {

	//freopen("input.txt","r",stdin);	

	scanf("%d",&n);

	ll mx=1;

	for(int i=1;i<=12;i++) {

		ll tut=mx;
		ll tut2=1;

		for(int j=1;j<=(i+1)/2;j++) {

			mul[j]=tut-tut2;

			tut/=10;
			tut2*=10;		

		}

		solve(1,(i+1)/2,i&1);

		mx*=10;

	}

	printf("%lld",ans);

}

Submission Info

Submission Time
Task F - Mirrored
User hamzqq9
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1512 Byte
Status WA
Exec Time 592 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:83:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^

Judge Result

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