标签:des style blog http color io os ar for
很弱的数据,随便搞
#include <iostream> #include <cstdio> #include <map> #include <string> #include <cstring> #include <vector> #include <algorithm> using namespace std; void debug() { cout<<"yes"<<endl; } int main() { //freopen("in","r",stdin); int T,n,i,j,k,m; bool vis[300]; string s[300]; map<string,int>box; map<string,int>::iterator it; cin>>T; getchar(); getchar(); for(k=0;k<T;k++) { if(k) cout<<endl; box.clear(); n=0; while(1) { getline(cin,s[n]); if(s[n][0]=='\0') break; n++; } for(i=0;i<n;i++) for(j=0;j<n;j++) { box[s[i]+s[j]]++; box[s[j]+s[i]]++; } m=n/2; for(it=box.begin();it!=box.end();it++) { if(it->second>=m) { memset(vis,0,sizeof(vis)); for(i=0;i<n;i++) { if(vis[i]) continue; for(j=i+1;j<n;j++) { if(!vis[j]&&(s[i]+s[j]==it->first||s[j]+s[i]==it->first)) { vis[j]=1; break; } } if(j==n) break; } if(i==n) { cout<<it->first<<endl; break; } } } } return 0; }
Time Limit:3000MS | Memory Limit:Unknown | 64bit IO Format:%lld & %llu |
Description
Your friend, a biochemistry major, tripped while carrying a tray of computer files through the lab. All of the files fell to the ground and broke. Your friend picked up all the file fragments and called you to ask for help putting them back together again.
Fortunately, all of the files on the tray were identical, all of them broke into exactly two fragments, and all of the file fragments were found. Unfortunately, the files didn‘t all break in the same place, and the fragments were completely mixed up by their fall to the floor.
You‘ve translated the original binary fragments into strings of ASCII 1‘s and 0‘s, and you‘re planning to write a program to determine the bit pattern the files contained.
The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.
Input will consist of a sequence of ``file fragments‘‘, one per line, terminated by the end-of-file marker. Each fragment consists of a string of ASCII 1‘s and 0‘s.
Output is a single line of ASCII 1‘s and 0‘s giving the bit pattern of the original files. If there are 2N fragments in the input, it should be possible to concatenate these fragments together in pairs to make N copies of the output string. If there is no unique solution, any of the possible solutions may be output.
Your friend is certain that there were no more than 144 files on the tray, and that the files were all less than 256 bytes in size.
1 011 0111 01110 111 0111 10111
01110111
标签:des style blog http color io os ar for
原文地址:http://blog.csdn.net/stl112514/article/details/40375171