File Fragmentation

很弱的数据,随便搞

#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;
}

UVA - 10132

File Fragmentation

Time Limit:3000MS   Memory Limit:Unknown   64bit IO Format:%lld & %llu

SubmitStatus

Description

Question 2: File Fragmentation

The Problem

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.

Input

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

For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.

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.

Sample Input

1

011
0111
01110
111
0111
10111

Sample Output

01110111
时间: 2024-10-10 00:04:42

File Fragmentation的相关文章

UVA File Fragmentation(文件复原)

Description Question 2: File Fragmentation The Problem 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

File Fragmentation Uva 10132

思路:最长的碎片和最短的碎片的组合中肯定有答案.所以先求长度,然后组合他们,最后检测组合结果字符串是否确保输入的碎片字符串都在其开始或结尾处. 总结:代码编写边注释,当你注释写不好的时候,说明你的思路也不是很清晰,请停下来思考,理清思路.下面这段代码是我注释得最详细的,因为我体会到,当自己写的程序不能AC的时候,搜搜看看别人没有注释的代码会更加让自己烦躁. #include<stdio.h> #include<string.h> void Reverse(char *strDest

UVA - 10132 File Fragmentation

题目大意:输入有点恶心,首先是case数,然后一个空行,然后再输入信息,然后又以一个空行结束该组数据,如果是最后一组数据了,不以空行结束,而是直接以EOF结束.输出,case之间有一个空行,最后一个case后面不要加空行 每组case的信息,就是N行的串,串中只有01,串的个数一定是偶数.原本有很多个一样的长串,每个长串都分成了两个短串但是分割的位置不一定相同即两个短串不一定是平分的(就是输入中的那些串).你要把这偶数个短串拼回那个长串(即2N个短串拼回N个相同的长串),如果有多种可能,任意一种

File System Design Case Studies

SRC=http://www.cs.rutgers.edu/~pxk/416/notes/13-fs-studies.html Paul Krzyzanowski April 24, 2014 Introduction We've studied various approaches to file system design. Now we'll look at some real file systems to explore the approaches that were taken i

UVA 10132-File Fragmentation(map还原字符串)

File Fragmentation The Problem 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 h

Performance Monitor Usage2:Peformance Counter

Performance Counter 是量化系统状态或活动的一个数值,对于不同的监控目的,需要设置不同的Performance Counter. Performance counters   are measurements of system state or activity. They can be included in the operating system or can be part of individual applications. Windows Performance

Nova:libvirt image 的生命周期

翻译自:http://www.pixelbeat.org/docs/openstack_libvirt_images/ The main stages of a Virtual Machine disk image as it transfers through OpenStack to be booted under libvirt are: Initially the image is downloaded from glance and cached in libvirt base. We

UVA题目分类

题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes

计划,,留

下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinejudge.org 西班牙Valladolid大学的程序在线评测系统,是历史最悠久.最著名的OJ. 一.<算法竞赛入门经典> 刘汝佳 (UVaOJ 351道题) 以下部分内容摘自:http://sdkdacm.5d6d.com/thread-6-1-1.html "AOAPC I"