本地(c++11)可以过,但在IDE(c++11和c++14)上不行。查了发现在IDE环境下,在这个循环内lst_ans莫名增加,但lst_ans在这动都没动过QwQ
for(int i=0;i<len_s;++i)
{
Id=i; memset(vis,0,sizeof(vis));
int now=str[i]-'0';
vis[now]=1;
dfs(now);
}
大晚上闹鬼怪吓人的TwT
code:
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define of(i,a,b) for(int i=a;i>=b;--i)
#define ll long long
#define P_B push_back
const int inf=0x3f3f3f3f;
const ll INF=9e18;
//const ll mod=;
const int N=20;
vector <int> no[N];
bool vis[N];
int ans[N];
int lst_ans[1000010];
int Id;
void dfs(int now)
{
++ans[Id];
int sze=no[now].size();
for(int i=0;i<sze;++i)
{
int nxt=no[now][i];
if(!vis[nxt]) {vis[nxt]=1; dfs(nxt);}
}
return ;
}
int main()
{
ios::sync_with_stdio(0);
string str; int k;cin>>str>>k;
fo(i,1,k)
{
int x,y;cin>>x>>y;
no[x].P_B(y);
}
int len_s=str.size();
for(int i=0;i<len_s;++i)
{
Id=i; memset(vis,0,sizeof(vis));
int now=str[i]-'0';
vis[now]=1;
dfs(now);
}
int tot_0=0;
lst_ans[1]=1; int len_lst=1;
for(int i=0;i<len_s;++i)
{
// cout<<"i:"<<i<<' '<<ans[i]<<endl;//
if(ans[i]==10) ++tot_0;
else
{
fo(j,1,len_lst) lst_ans[j]*=ans[i];
fo(j,1,len_lst)
{
while(lst_ans[len_lst+1]) ++len_lst;
if(lst_ans[j]>9)
{
lst_ans[j+1]+=lst_ans[j]/10;
lst_ans[j]%=10;
}
}
while(lst_ans[len_lst+1]) ++len_lst;
}
// of(i,len_lst,1) cout<<lst_ans[i]; cout<<endl;//
}
of(i,len_lst,1) cout<<lst_ans[i];
while(tot_0--) cout<<'0';
cout<<endl;
return 0;
}
/*
in1:
6554443333222221111110000000 15
0 1
0 2
0 3
0 4
0 5
0 6
1 2
2 3
3 1
4 5
5 6
6 4
7 8
7 9
1 7
out1:
3427648537559040000000
3427648537559040000000
*/
in:
6554443333222221111110000000 15
0 1
0 2
0 3
0 4
0 5
0 6
1 2
2 3
3 1
4 5
5 6
6 4
7 8
7 9
1 7
out(本地):
3427648537559040000000
out(IDEc++14,无o2):
80654855187789244320000
救命呜呜呜