QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#397759 | #3754. Numbers | Graphcity# | AC ✓ | 23ms | 3472kb | C++20 | 710b | 2024-04-24 16:45:53 | 2024-04-24 16:45:54 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 23ms
memory: 3472kb
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