Submission #46559715


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+
(x<<3)+(ch^48);ch=getchar();}return x*f;}
#define Z(x) (x)*(x)
#define pb push_back
//#define M
//#define mo
//#define N
int n, m, i, j, k, T;
int ans, c[15], d[15]; 
char s[15]; 

void calc(int x) {
	int i, y=x; 
//	if(x==324) printf("-----\n"); 
	memcpy(d, c, sizeof(c)); 
	for(i=1; i<=n || x; ++i) {
		d[x%10]--; 
//		if(y==283024) printf("%d\n", x%10); 
		if(d[x%10]<0) return ; 
		x/=10; 
	}
//	printf("%lld\n", y); 
	++ans; 
}

signed main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
//	srand(time(NULL));
//	T=read();
//	while(T--) {
//
//	}
	n=read(); 
	scanf("%s", s+1); 
	for(i=1; i<=n; ++i) c[s[i]-'0']++; 
//	for(i=0; i<10; ++i) printf("%d ", c[i]); printf("\n"); 
	for(i=0; i<=1e7; ++i) {
		k=i*i; 
		calc(k); 
	}
	cout<<ans; 
	return 0;
}

Submission Info

Submission Time
Task D - Square Permutation
User zhangtingxi
Language C++ 20 (gcc 12.2)
Score 425
Code Size 1036 Byte
Status AC
Exec Time 231 ms
Memory 3840 KiB

Compile Error

Main.cpp: In function ‘void calc(long long int)’:
Main.cpp:18:16: warning: unused variable ‘y’ [-Wunused-variable]
   18 |         int i, y=x;
      |                ^
Main.cpp: In function ‘int main()’:
Main.cpp:41:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   41 |         scanf("%s", s+1);
      |         ~~~~~^~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 46
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 02_max_23.txt, 02_max_24.txt, 02_max_25.txt, 02_max_26.txt, 02_max_27.txt, 02_max_28.txt, 02_max_29.txt, 02_max_30.txt, 02_max_31.txt, 02_max_32.txt, 02_max_33.txt, 02_max_34.txt, 02_max_35.txt, 03_small_36.txt, 03_small_37.txt, 03_small_38.txt, 03_small_39.txt, 03_small_40.txt, 03_small_41.txt, 03_small_42.txt, 03_small_43.txt, 03_small_44.txt, 03_small_45.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 37 ms 3564 KiB
00_sample_01.txt AC 37 ms 3736 KiB
00_sample_02.txt AC 228 ms 3672 KiB
01_random_03.txt AC 180 ms 3644 KiB
01_random_04.txt AC 81 ms 3680 KiB
01_random_05.txt AC 33 ms 3660 KiB
01_random_06.txt AC 178 ms 3664 KiB
01_random_07.txt AC 87 ms 3676 KiB
01_random_08.txt AC 103 ms 3836 KiB
01_random_09.txt AC 172 ms 3736 KiB
01_random_10.txt AC 114 ms 3584 KiB
01_random_11.txt AC 156 ms 3620 KiB
01_random_12.txt AC 149 ms 3592 KiB
01_random_13.txt AC 94 ms 3668 KiB
01_random_14.txt AC 48 ms 3840 KiB
01_random_15.txt AC 43 ms 3644 KiB
01_random_16.txt AC 141 ms 3540 KiB
01_random_17.txt AC 124 ms 3648 KiB
01_random_18.txt AC 148 ms 3540 KiB
01_random_19.txt AC 52 ms 3800 KiB
01_random_20.txt AC 88 ms 3616 KiB
01_random_21.txt AC 63 ms 3732 KiB
01_random_22.txt AC 193 ms 3524 KiB
02_max_23.txt AC 231 ms 3588 KiB
02_max_24.txt AC 227 ms 3644 KiB
02_max_25.txt AC 225 ms 3656 KiB
02_max_26.txt AC 221 ms 3800 KiB
02_max_27.txt AC 219 ms 3736 KiB
02_max_28.txt AC 32 ms 3568 KiB
02_max_29.txt AC 37 ms 3736 KiB
02_max_30.txt AC 42 ms 3656 KiB
02_max_31.txt AC 36 ms 3732 KiB
02_max_32.txt AC 33 ms 3644 KiB
02_max_33.txt AC 41 ms 3740 KiB
02_max_34.txt AC 40 ms 3580 KiB
02_max_35.txt AC 43 ms 3640 KiB
03_small_36.txt AC 32 ms 3640 KiB
03_small_37.txt AC 33 ms 3644 KiB
03_small_38.txt AC 30 ms 3732 KiB
03_small_39.txt AC 31 ms 3616 KiB
03_small_40.txt AC 33 ms 3636 KiB
03_small_41.txt AC 31 ms 3732 KiB
03_small_42.txt AC 33 ms 3732 KiB
03_small_43.txt AC 31 ms 3668 KiB
03_small_44.txt AC 31 ms 3728 KiB
03_small_45.txt AC 32 ms 3728 KiB