标签:key stream href prot other eof 分享图片 problems style
Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4217 Accepted Submission(s): 2020
#include<iostream> #include<cstdio> #include<cstdlib> #include<sstream> #include<cstring> #include<string> #include<vector> #include<set> #include<stack> #include<queue> #include<map> #include<cmath> #include<algorithm> using namespace std; #define inf 0x3f3f3f3f #define ll long long #define MAX_N 1000005 #define gcd(a,b) __gcd(a,b) #define mem(a,x) memset(a,x,sizeof(a)) #define mid(a,b) a+b/2 #define stol(a) atoi(a.c_str())//string to long string temp[10]; string c = "ACGT"; int pos[10]; int len[10]; int deep; int n; int ans(){ int maxn = 0; for(int i = 0; i < n; i++){ maxn = max(maxn,len[i]-pos[i]); } return maxn; } int dfs(int step){ if(step + ans() > deep) return 0; if(!ans())//满足构造序列包含所有序列 return 1; int temp1[10]; for(int i = 0; i < 4; i++){ int flag = 0; for(int j = 0; j < n; j++) temp1[j] = pos[j]; for(int j = 0; j < n; j++){ if(temp[j][pos[j]] == c[i]){ flag = 1; pos[j]++; } } if(flag){ if(dfs(step+1)) return 1; for(int j = 0; j < n; j++) pos[j] = temp1[j]; } } return 0; } int main(){ // freopen("D:\\in.txt","r",stdin); int T; scanf("%d",&T); while(T--){ scanf("%d",&n); deep = 0; for(int i = 0; i < n; i++){ cin>>temp[i]; len[i] = temp[i].length(); pos[i] = 0; deep = max(deep,len[i]); } while(1){ if(dfs(0)) break; ++deep; } printf("%d\n",deep); } return 0; }
标签:key stream href prot other eof 分享图片 problems style
原文地址:https://www.cnblogs.com/zaorunzi/p/9840251.html