QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397996#3754. NumbersGraphcityAC ✓27ms3592kbC++20710b2024-04-24 21:04:362024-04-24 21:04:37

Judging History

This is the latest submission verdict.

  • [2024-04-24 21:04:37]
  • Judged
  • Verdict: AC
  • Time: 27ms
  • Memory: 3592kb
  • [2024-04-24 21:04:36]
  • Submitted

answer

#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int Maxn=2e5;

string s; int n,a[100],vis[100],ans;

inline void dfs(int x)
{
    if(x>n) {ans++; return;}
    if(!vis[a[x]]) vis[a[x]]=1,dfs(x+1),vis[a[x]]=0;
    if(x<n && a[x] && !vis[a[x]*10+a[x+1]])
        vis[a[x]*10+a[x+1]]=1,dfs(x+2),vis[a[x]*10+a[x+1]]=0;
}
inline void Solve()
{
    n=s.size(),s=' '+s,ans=0;
    For(i,1,n) a[i]=s[i]-'0';
    dfs(1),cout<<ans<<endl;
}

int main()
{
    // freopen("1.in","r",stdin);

    while(cin>>s) Solve();
    // cerr<<1.0*clock()/CLOCKS_PER_SEC<<endl;
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 27ms
memory: 3592kb

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