fork(6) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9. class Program
  10. {
  11.  
  12. static void Main(string[] args)
  13. {
  14. int x;
  15. x=Int32.Parse(Console.ReadLine());
  16. Dictionary<string, int> dict = new Dictionary<string, int>();
  17. List<string> erdos = new List<string>();
  18. List<string> wszystko = new List<string>();
  19. Dictionary<string, List<string>> biblio = new Dictionary<string, List<string>>();
  20.  
  21. for (int i = 0; i < x; i++)
  22. {
  23. string line = Console.ReadLine();
  24. string surname, article;
  25. surname = line.Split(' ')[0];
  26. article = line.Split('"')[1].Replace('"', new char());
  27. if (biblio.ContainsKey(surname))
  28. {
  29. biblio[surname].Add(article);
  30. }
  31. else
  32. biblio.Add(surname, new List<string>() {article});
  33. }
  34. foreach (var item in biblio)
  35. {
  36. dict.Add(item.Key, -1);
  37. }
  38. if (dict.Keys.Contains("P.Erdos")) dict["P.Erdos"] = 0;
  39. int n = 0;
  40. while(dict.Values.Contains(n))
  41. {
  42. foreach (var it in biblio)
  43. {
  44. if (dict[it.Key] == n)
  45. {
  46. foreach (var item in biblio[it.Key])
  47. {
  48. foreach (var surname in biblio.Keys)
  49. {
  50. if (biblio[surname].Contains(item) && !surname.Equals("P.Erdos") && dict[surname] < 0)
  51. {
  52. dict[surname] = n + 1;
  53. }
  54. }
  55. }
  56. }
  57.  
  58. }
  59. n++;
  60. }
  61. //foreach (var item in biblio["P.Erdos"])
  62. //{
  63. // foreach (var surname in biblio.Keys)
  64. // {
  65. // if (biblio[surname].Contains(item) && !surname.Equals("P.Erdos"))
  66. // {
  67. // dict[surname] = 1;
  68. // }
  69. // }
  70. //}
  71.  
  72. //foreach (var item in dict)
  73. //{
  74. // Console.WriteLine(item.Key + " " + item.Value);
  75. //}
  76. var list = dict.Keys.ToList();
  77. list.Sort();
  78. foreach (var item in list)
  79. {
  80. if(dict[item]==-1)
  81. Console.WriteLine(item + ": " + "inf");
  82. else
  83. Console.WriteLine(item+": "+ dict[item]);
  84. }
  85. }
  86. }
  87. }
  88.  
Success #stdin #stdout 0.01s 132096KB
stdin
18
W.Rytter "On polynomial-time approximation algorithms for the variable length scheduling problem"
E.Kopczynski "Definability of linear equation systems over groups and rings"
M.Pilipczuk "Breaking the 2^n-barrier for irredundance: two lines of attack"
P.Erdos "Regulare Graphen gegebener Taillenweite mit minimaler Knotenzahl"
M.Cygan "Breaking the 2^n-barrier for irredundance: two lines of attack"
R.Krishnamurti "On polynomial-time approximation algorithms for the variable length scheduling problem"
P.Erdos "Imbalances in k-colorations"
E.Gradel "Scott Finite model theory and its applications"
D.Kratsch "Breaking the 2^n-barrier for irredundance: two lines of attack"
E.Gradel "Definability of linear equation systems over groups and rings"
H.Sachs "Berge's theorem for the maximum charge problem"
R.Krishnamurti "Berge's theorem for the maximum charge problem"
D.Kratsch "Dieter Some extremal results in cochromatic and dichromatic theory"
H.Sachs "Regulare Graphen gegebener Taillenweite mit minimaler Knotenzahl"
J.Spencer "Scott Finite model theory and its applications"
J.Spencer "Imbalances in k-colorations"
P.Erdos "Dieter Some extremal results in cochromatic and dichromatic theory"
L.Godeaux "Les involutions cycliques appartenant a une surface algebrique"
stdout
D.Kratsch: 1
E.Gradel: 2
E.Kopczynski: 3
H.Sachs: 1
J.Spencer: 1
L.Godeaux: inf
M.Cygan: 2
M.Pilipczuk: 2
P.Erdos: 0
R.Krishnamurti: 2
W.Rytter: 3