QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397896#3754. Numbersxlwang#AC ✓26ms3836kbC++141.7kb2024-04-24 19:18:432024-04-24 19:18:44

Judging History

你现在查看的是最新测评结果

  • [2024-04-24 19:18:44]
  • 评测
  • 测评结果:AC
  • 用时:26ms
  • 内存:3836kb
  • [2024-04-24 19:18:43]
  • 提交

answer

#include<bits/stdc++.h>
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
using namespace std;
inline int read(){
	int x=0;
	bool f=0;
	char c=getchar();
	while(!isdigit(c)) f|=(c=='-'),c=getchar();
	while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?-x:x;
}
inline void write(int x){
    if(x<0){putchar('-');x=-x;}
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
int vis[200];
const int Maxn=1e2+10;
char c[Maxn];
int ans;
int n;
inline void dfs(int x){
    // cout<<x<<endl;
    if(x==n+1){
        ++ans;return;
    }
    if(c[x]=='0'){
        if(vis[0]) return;
        vis[0]=1;
        dfs(x+1);
        vis[0]=0;
        return;
    }
    int id=c[x]-'0';
    // cout<<"*"<<id<<endl;
    if(!vis[id]){
        vis[id]=1;
        dfs(x+1);
        vis[id]=0;
    }
    if(x==n) return;
    id=(c[x]-'0')*10+(c[x+1]-'0');
    // cout<<"**"<<id<<endl;
    if(!vis[id]){
        vis[id]=1;
        dfs(x+2);
        vis[id]=0;
    }
}
inline void work(){
    ans=0;n=strlen(c+1);
    fr(i,0,99) vis[i]=0;
    dfs(1);
    writeln(ans);
}
inline void init(){
    while(scanf("%s",c+1)!=EOF) work();
}
signed main(){
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
    init();
    // printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 26ms
memory: 3836kb

input:

0385596
623829532127833595190856470573136145815442523489
3766945901332141272257649782082688342526804752
196131806875116663514046841347546471452538379741
114804665712451327453562583855203785123521571392
45308531262867824688749760418132337858154164338
81404731326615336971856750588837772991621753879
52...

output:

9
46469
10936
7508
4466
6048
36048
0
6740
0
5850
1
2392
1012
10460
6358
9756
149
0
1766
5945
8131
0
14611
3
10159
5897
12161
11403
8892
0
4386
159
835
3731
7751
0
28118
1982
361
8674
190
9570
15012
362
8634
26
13347
1273
4486
3379
301
0
938
34
14984
14437
4898
0
10590
7848
8
15308
16167
11072
12342
...

result:

ok 100 numbers