当前位置:网站首页>牛的学术圈 II(春季每日一题 49)
牛的学术圈 II(春季每日一题 49)
2022-06-22 05:31:00 【sweetheart7-7】
Bessie 正在申请计算机科学的研究生,并取得了一所久负盛名的计算机科学实验室的面试通知。
然而,为了避免冒犯任何人,Bessie 有意先确定实验室的 N N N 名现有成员的相对资历。
没有两名实验室成员的资历相同,但确定他们的资历深浅可能并不好办。
为此,Bessie 将会对实验室的出版物进行调查。
每份出版物均包含一个作者列表,为所有 N N N 名实验室成员的一个排列。
列表按每名实验室成员对这篇文章的贡献降序排列。
如果多名研究员的贡献相等,则按字典序排列。
由于更有资历的实验室成员负有更多的管理责任,更有资历的研究员从不会比资历较浅的研究员做出更多的贡献。
例如,在一个由资历较浅的学生 Elsie、资历较深的教授 Mildred、以及十分资深的教授 Dean 组成的实验室中,可能存在一篇论文 E l s i e − M i l d r e d − D e a n Elsie-Mildred-Dean Elsie−Mildred−Dean,如果他们做出了不等的贡献(也就是说,Elsie 做出的贡献比 Mildred 更多,Mildred 比 Dean 更多)。
然而,也有可能存在一篇论文 E l s i e − D e a n − M i l d r e d Elsie-Dean-Mildred Elsie−Dean−Mildred,如果 Mildred 和 Dean 做出了相等的贡献,而 Elsie 做出了更多的贡献。
给定实验室的 K K K 份出版物,对于实验室中每对研究员,如果可能的话帮助 Bessie 判断其中谁的资历更深。
输入格式
输入的第一行包含两个整数 K K K 和 N N N。
第二行包含 N N N 个空格分隔的字符串,为实验室的成员的名字。每个字符串均由小写字母组成,且至多包含 10 10 10 个字符。
以下 K K K 行,每行包含 N N N 个空格分隔的字符串,表示一份出版物的作者列表。
输出格式
输出 N N N 行,每行 N N N 个字符。在第 i i i 行内,对于所有 j ≠ i j≠i j=i,当可以确定第 i i i 名成员比第 j j j 名成员资历更深时字符 j j j 为 1,当可以确定第 i i i 名成员比第 j 名成员资历更浅时字符 j j j 为 0,当不能由给定的出版物确定时为 ?。
第 i i i 行的字符 i i i 应为 B B B,因为这是 Bessie 最喜欢的字母。
数据范围
1 ≤ N , K ≤ 100 1≤N,K≤100 1≤N,K≤100
输入样例1:
1 3
dean elsie mildred
elsie mildred dean
输出样例1:
B11
0B?
0?B
样例1解释
在这个样例中,单独一份论文 elsie-mildred-dean 并不能提供足够的信息判断 Elsie 比 Mildred 资历更深或更浅。
然而,我们可以推断出 Dean 一定比这两名研究员资历更深,从而资历排序为 E l s i e < M i l d r e d < D e a n Elsie<Mildred<Dean Elsie<Mildred<Dean 和 M i l d r e d < E l s i e < D e a n Mildred<Elsie<Dean Mildred<Elsie<Dean 均是可能的。
输入样例2:
2 3
elsie mildred dean
elsie mildred dean
elsie dean mildred
输出样例2:
B00
1B0
11B
样例2解释
在这个样例中,唯一能与两篇论文相一致的资历排序为 E l s i e < M i l d r e d < D e a n Elsie<Mildred<Dean Elsie<Mildred<Dean,这是因为基于第一个样例所提供的信息,第二篇论文可以帮助我们推断出 Mildred 比 Elsie 的资历更深。
#include<iostream>
#include<unordered_map>
#include<cstring>
using namespace std;
const int N = 110;
int n, k;
int a[N][N];
unordered_map<string, int> mp;
string s[N], p[N];
int comp(int f1, int f2){
string s1 = p[f1], s2 = p[f2];
for(int i = 0; i < k; i++)
if(a[i][mp[s1]] > a[i][mp[s2]]) return 1;
else if(a[i][mp[s1]] < a[i][mp[s2]]) return -1;
return 0;
}
int main(){
cin >> k >> n;
string name;
for(int i = 0; i < n; i++) cin >> p[i], mp[p[i]] = i;
for(int i = 0; i < k; i++){
for(int j = 0; j < n; j++){
cin >> s[j];
if(j && s[j] > s[j-1]) a[i][mp[s[j]]] = a[i][mp[s[j-1]]];
else a[i][mp[s[j]]] = j;
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(i == j) cout << 'B';
else{
int res = comp(i, j);
if(res == 1) cout << 1;
else if(res == -1) cout << 0;
else cout << '?';
}
}
cout << endl;
}
return 0;
}
边栏推荐
- Optimization direction of code walk through (convenient interface requests, long dynamic class judgment conditions, removal of useless consoles, separation of public methods)
- 记录在处理SIF数据中,遇到的一些问题及解决过程
- 给仍在「 选品 」的跨境卖家提个醒!
- Global and Chinese aluminum electrolytic capacitor market survey and future development strategic planning report 2022-2027
- 为什么说“ CPS联盟营销 ” 是性价比最高的推广方式?
- c files always get rebuild when make -------- . PHONY in Makefile
- Summary of knapsack problem
- Go语言使用JWT
- Learning method 4 for promotion of big factories: play learning method
- Sourcetree reported an error SSH failure
猜你喜欢

Sogou input method cannot output Chinese

Graduation season | a new start, no goodbye

Machine learning note 7: powerful neural network representation

基于WebUploader实现大文件分片上传

C#中Cookie设置与读取

北峰助力南昌市应急管理局打造公专融合应急通信保障网

记录在处理SIF数据中,遇到的一些问题及解决过程

Analysis of 43 cases of MATLAB neural network: Chapter 29 research on the application of limit learning machine in regression fitting and classification -- Comparative Experiment

Does the air valve perform the en 1634-1 fire resistance test for 4 hours?

Use and decoupling of the mobile terminal's realm database, and use OC realm safely across threads
随机推荐
Performance analysis and test of interprocess communication methods under dual core real-time system
机器学习笔记 七:强大的神经网络表述
Remove then add string from variable of Makefile
从“ 平台转型 ”到“ DTC品牌出海 ”,2021趋势何在?
CMAKE notes
为什么说“ CPS联盟营销 ” 是性价比最高的推广方式?
Implementation of large file fragment uploading based on webuploader
面对Google流量红利期,独立站卖家如何借势营销?
Development planning and investment strategy analysis report of global and Chinese microwave ablation industry during the 14th Five Year Plan period 2022-2027
跨境政策频调整 “ 独立站&平台 ” 哪个才是趋势所在?
Delete the packaging use of pop-up components
用简单方法实现对象的深克隆封装js
open source hypervisor
C#中Cookie设置与读取
I don't suggest you work too hard
Throw away electron and embrace Tauri based on Rust
亚马逊和独立站,不是简单的二选一
Current market situation analysis and investment analysis prospect report of global and Chinese ceramic capacitor industry 2022-2027
count registers in C code -- registers has one pattern
A simple method to implement deep cloning and encapsulation of objects JS