为什么下载数据点自己测试是ac的,评测是wa的
查看原帖
为什么下载数据点自己测试是ac的,评测是wa的
940317
lightme楼主2024/1/10 12:17

懵了家人们一下是源码

#include<iostream>
#include<algorithm>
//#include<cstdio>
#include<cstring>
#define ll long long 
#define endl '\n'
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>(b);i--)
#define N 1000100 //1e6+100 
 
using namespace std;
string strn;
int k,x,y;
int num[40];
bool st[10][10];
bool pa[10][10];
int ans;
void dfs(int x){
	
	rep(i,0,10){
		if(st[x][i]&&!pa[x][i]){
			pa[x][i]=true;
			pa[i][x]=true;
			ans++;
			dfs(i);
		}
	}
}
int main(){
	//ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>strn>>k;
	for(int i=0;i<strn.size();i++){
		num[i]=(char)strn[i]-'0';
	}
	// rep(i,0,10){
		// st[i][i]=true;
	// }
	rep(i,0,k){
		cin>>x>>y;
		st[x][y]=true;
	}
	ll cnt=1;
	int len=strn.size();
	rep(i,0,len){
		memset(pa,0,sizeof pa);
		pa[i][i]=true;
		ans=1;
		dfs(num[i]);
		cnt*=ans;
	}
	cout<<cnt<<endl;
	return 0; 
} 


附#3和#4测试点

in:

11111111111111111111 2 1 2 2 1

out:

1048576

in:

12345678901234567890 9 2 1 3 2 4 3 5 4 6 5 7 6 8 7 9 8 0 9

out:

13168189440000

2024/1/10 12:17
加载中...