Submission #46553548


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(i, j, n) for (ll i = (ll)(j); i <= (ll)(n); ++i)
#define all(v) v.begin(), v.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9 + 7;
const int mod = 998244353;
const ll INF = 2e15;
template <class T>
void print(const T& t) {
  cout << t << endl;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

/*
ll ti=clock();
cout<<("Execution Time: %.4lf sec", 1.0 * (clock() - ti) /
CLOCKS_PER_SEC)<<endl;
*/

int main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  vl s_count(10,0);
  rep(i,sz(s)){
    s_count[s[i]-'0']++;
  }
  ll answer=0;
  for(ll i=0; i*i<=1e14;i++){
    ll x=i*i;
    string t=to_string(x);
    vl t_count(10,0);
    rep(j,sz(t)){
      t_count[t[j]-'0']++;
    }
    if(t_count[0]>s_count[0]){
      continue;
    }
    bool ok=true;
    Rep(j,1,9){
      if(t_count[j]!=s_count[j]){
        ok=false;
      }
    }
    if(ok){
      answer++;
    }
  }
  print(answer);
}

Submission Info

Submission Time
Task D - Square Permutation
User replica
Language C++ 20 (gcc 12.2)
Score 425
Code Size 1542 Byte
Status AC
Exec Time 447 ms
Memory 3656 KiB

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 406 ms 3460 KiB
00_sample_01.txt AC 399 ms 3524 KiB
00_sample_02.txt AC 447 ms 3480 KiB
01_random_03.txt AC 408 ms 3560 KiB
01_random_04.txt AC 385 ms 3532 KiB
01_random_05.txt AC 383 ms 3464 KiB
01_random_06.txt AC 408 ms 3456 KiB
01_random_07.txt AC 408 ms 3444 KiB
01_random_08.txt AC 383 ms 3456 KiB
01_random_09.txt AC 382 ms 3572 KiB
01_random_10.txt AC 383 ms 3464 KiB
01_random_11.txt AC 408 ms 3492 KiB
01_random_12.txt AC 446 ms 3444 KiB
01_random_13.txt AC 383 ms 3488 KiB
01_random_14.txt AC 401 ms 3440 KiB
01_random_15.txt AC 409 ms 3464 KiB
01_random_16.txt AC 408 ms 3532 KiB
01_random_17.txt AC 407 ms 3496 KiB
01_random_18.txt AC 401 ms 3360 KiB
01_random_19.txt AC 390 ms 3468 KiB
01_random_20.txt AC 389 ms 3656 KiB
01_random_21.txt AC 384 ms 3472 KiB
01_random_22.txt AC 400 ms 3468 KiB
02_max_23.txt AC 407 ms 3468 KiB
02_max_24.txt AC 400 ms 3564 KiB
02_max_25.txt AC 390 ms 3444 KiB
02_max_26.txt AC 408 ms 3464 KiB
02_max_27.txt AC 385 ms 3420 KiB
02_max_28.txt AC 383 ms 3360 KiB
02_max_29.txt AC 408 ms 3492 KiB
02_max_30.txt AC 407 ms 3360 KiB
02_max_31.txt AC 383 ms 3360 KiB
02_max_32.txt AC 382 ms 3524 KiB
02_max_33.txt AC 383 ms 3508 KiB
02_max_34.txt AC 408 ms 3456 KiB
02_max_35.txt AC 383 ms 3656 KiB
03_small_36.txt AC 409 ms 3456 KiB
03_small_37.txt AC 383 ms 3404 KiB
03_small_38.txt AC 385 ms 3488 KiB
03_small_39.txt AC 383 ms 3476 KiB
03_small_40.txt AC 383 ms 3420 KiB
03_small_41.txt AC 382 ms 3460 KiB
03_small_42.txt AC 382 ms 3480 KiB
03_small_43.txt AC 382 ms 3448 KiB
03_small_44.txt AC 382 ms 3424 KiB
03_small_45.txt AC 382 ms 3460 KiB