Music Mess

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/gym/100463/attachments

Description

Francis really likes his music. He especially likes that song ’Zombie Nation’. Or was that the album? Or maybe the album was ’Kernkraft 400’. Would anybody really name an album that though? Francis doesn’t know and he can’t be expected to remember such matters. He’s a humble guy and won’t be offended if you correct him. Not all is lost though. Francis does remember the names of the artist, album, and track for some of the songs in his music collection. The only problem is he can’t seem to remember which names correspond to what. Luckily for you he does remember that there are no duplicates in the set of all artist, album, and track names. Additionally Francis’ music collection is hierarchical. At the top level he has one or more artists. Each artist then may have one or more albums. Each album then may have one or more tracks. Therefore each track appears on exactly one album and each album was authored by exactly one artist. Help him out by figuring out which names could be artists, which could be albums, and which could be songs.

Input

There are several test cases in the input file. Each test case starts with a single line containing N (1 ≤ N ≤ 10, 000), the number of tracks in Francis’ collection. The following N lines contain 3 names composed only of characters (a-z, A-Z, 0-9) indicating the artist, album, and track of a single song provided in an unknown order. Each string will contain between 1 and 20 characters. The input is terminated with a line containing 0. The input for each test case will always correspond to at least one legal music library obeying the rules above.

Output

For each case of the input print out the case number followed by three numbers separated by a space. The first indicating how many names could correspond to artists, the second to albums, and the third to tracks. Follow the format shown below.

Sample Input

2 ZombieNation Kernkraft400 Leichenschmaus Zombielicious ZombieNation Supercake53 2 Doolittle Silver Pixies Pixies Doolittle Tame 0

Sample Output

Case 1: 1 4 4 Case 2: 2 2 2

HINT

题意

有一堆名字,告诉你其中每一排名字有一个是作者,有一个是专辑,有一个是歌曲名,然后让你说出,有多少个名字可以当作者,多少个可以当专辑,多少个可以当歌曲

其中歌曲有一个专辑,专辑会有一个歌手

题解:

其实就是处理各种关系啦

出现一次的肯定是歌曲啦

然后剪不断,理还乱,看注释吧~

代码

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
const int maxn=;
#define mod 1000000007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** map<string,int> m,p[];
string s[maxn][];
char t[][];
bool cmp(string x,string y)
{
return m[x]>m[y];
}
int main()
{
int t=;
int n;
while(cin>>n)
{
if(n==)
break;
m.clear();
for(int i=;i<;i++)p[i].clear();
for(int i=;i<n;i++)
{
for(int j=;j<;j++)
{
cin>>s[i][j];
m[s[i][j]]++;
}
}
for(int i=;i<n;i++)
{
sort(s[i],s[i]+,cmp);
int a=m[s[i][]];
int b=m[s[i][]];
int c=m[s[i][]];
if(a==)//当都出现一次的时候,所有东西都可以混着用
{
for(int j=;j<;j++)
{
p[j][s[i][]]=p[j][s[i][]]=p[j][s[i][]]=;
}
}
else if(b==)//当有俩只出现1次的时候,这两个很显然可以混着用,第一个必然为歌唱家
{
p[][s[i][]]=;
for(int j=;j<;j++)
p[j][s[i][]]=p[j][s[i][]]=;
}
else if(a==b)//歌唱家和专辑可以混着用
{
p[][s[i][]]=;
for(int j=;j<;j++)
p[j][s[i][]]=p[j][s[i][]]=;
}
else//各用个的
{
for(int j=;j<;j++)
p[j][s[i][j]]=;
}
}
printf("Case %d: %d %d %d\n",t++,p[].size(),p[].size(),p[].size());
}
}

Codeforces Gym 100463B Music Mess Hash 逻辑题的更多相关文章

  1. Codeforces Gym 100269B Ballot Analyzing Device 模拟题

    Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...

  2. Codeforces Gym 100269A Arrangement of Contest 水题

    Problem A. Arrangement of Contest 题目连接: http://codeforces.com/gym/100269/attachments Description Lit ...

  3. codeforces Gym 100187H H. Mysterious Photos 水题

    H. Mysterious Photos Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...

  4. codeforces Gym 100500H H. ICPC Quest 水题

    Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...

  5. Codeforces Gym 100513F F. Ilya Muromets 水题

    F. Ilya Muromets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/probl ...

  6. CF Gym 100463B Music Mess (思路)

    好题,当时想了半个小时,我往图论方面去想了,把出现过的字符串当场点,然后相互连边,那么就构成了一个三角形,一个大于三个点的连通分量里有以下结论:度为二的点可能是track,度为大于二的点一定不是tra ...

  7. Codeforces Gym 101252D&&floyd判圈算法学习笔记

    一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...

  8. Codeforces gym 101343 J.Husam and the Broken Present 2【状压dp】

     2017 JUST Programming Contest 2.0 题目链接:Codeforces gym 101343 J.Husam and the Broken Present 2 J. Hu ...

  9. 2014百度之星资格赛 1001:Energy Conversion(水题,逻辑题)

    Energy Conversion Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

随机推荐

  1. Android开发中这些小技巧

    http://blog.csdn.net/guxiao1201/article/details/40655661 http://blog.csdn.net/guxiao1201/article/det ...

  2. 正则 提取html标签value

    using System.Text.RegularExpressions; //step2: extract expected info //<h1 class="h1user&quo ...

  3. Android 数独游戏 记录

    Android图形编程基本概念 颜色对象 Color 类 int color = Color.bule    //蓝色 int color = Color.argb(255,255,255,255); ...

  4. Android应用解决65K方法数限制

    近日,Android Developers在Google+上宣布了新的Multidex支持库,为方法总数超过65K的Android应用提供了官方支持. 如果你是一名幸运的Android应用开发者,正在 ...

  5. hadoop的kerberos认证

    言归正传,介绍过hadoop的simple认证和kerberos后,我们在这一章介绍hadoop的kerberos认证 我们还使用hadoop集群的机器. OS 版本: Centos6.4 Kerbe ...

  6. 关于WordPress建站的原理二三事

    在写关于仿站文章详情页如何制作之前,我觉得有必要就一些原理性的问题,做一些说明.文章详情页的核心模块和首页有很多相似的地方,比如调用文章的标题.文章的内容.文章分类.作者等,实现起来都差不多,因此,了 ...

  7. 使用nodejs中httpProxy代理时候出现404异常

    在公司中使用nodejs构建代理服务器实现前后台分离,代码不能拿出来,然后出现httpProxy代理资源的时候老是出现404.明明被代理的接口是存在的.代码大概如下: var http = requi ...

  8. Python 批量创建同文件名的特定后缀文件

    看了很多批量创建文件和文件批量格式转换的code,感觉杀鸡焉用牛刀,自己写了几行轻量级的拿来给大家参考: 在out_dir目录下批量创建与in_dir目录下同文件名但后缀不同的文件. in_dir = ...

  9. POJ 2395 Out of Hay(MST)

    [题目链接]http://poj.org/problem?id=2395 [解题思路]找最小生成树中权值最大的那条边输出,模板过的,出现了几个问题,开的数据不够大导致运行错误,第一次用模板,理解得不够 ...

  10. 轻松学习Linux之认识内存管理机制

    本文出自 "李晨光原创技术博客" 博客,谢绝转载!