fork download
  1. /*-------property of the half blood prince-----*/
  2.  
  3. #include <bits/stdc++.h>
  4. #include <dirent.h>
  5. #include <ext/pb_ds/assoc_container.hpp>
  6. #include <ext/pb_ds/tree_policy.hpp>
  7. #include <ext/pb_ds/detail/standard_policies.hpp>
  8. #define MIN(X,Y) X<Y?X:Y
  9. #define MAX(X,Y) X>Y?X:Y
  10. #define ISNUM(a) ('0'<=(a) && (a)<='9')
  11. #define ISCAP(a) ('A'<=(a) && (a)<='Z')
  12. #define ISSML(a) ('a'<=(a) && (a)<='z')
  13. #define ISALP(a) (ISCAP(a) || ISSML(a))
  14. #define MXX 10000000000
  15. #define MNN -MXX
  16. #define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
  17. #define LLI long long int
  18. #define VI vector<int>
  19. #define VLLI vector<long long int>
  20. #define MII map<int,int>
  21. #define SI set<int>
  22. #define PB push_back
  23. #define MSI map<string,int>
  24. #define PII pair<int,int>
  25. #define PLLI pair<LLI,LLI>
  26. #define PDD pair<double,double>
  27. #define FREP(i,I,N) for(int (i)=(int)(I);(i)<=(int)(N);(i)++)
  28. #define eps 0.0000000001
  29. #define RFREP(i,N,I) for(int (i)=(int)(N);(i)>=(int)(I);(i)--)
  30. #define SORTV(VEC) sort(VEC.begin(),VEC.end())
  31. #define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
  32. #define REVV(VEC) reverse(VEC.begin(),VEC.end())
  33. #define INRANGED(val,l,r) (((l)<(val) || fabs((val)-(l))<eps) && ((val)<(r) || fabs((val)-(r))<eps))
  34. #define INRANGEI(val,l,r) ((val)>=(l) && (val)<=(r))
  35. #define MSET(a,b) memset(a,b,sizeof(a))
  36. using namespace std;
  37. using namespace __gnu_pbds;
  38.  
  39. //int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
  40. //int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
  41. //int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
  42. //int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction
  43.  
  44.  
  45. //typedef tree < int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
  46.  
  47. set<string>alls;
  48. vector<string>allv;
  49.  
  50. pair<bool,string> getstr(int L, int n){
  51. string s = "";
  52. FREP(i,0,(L-1)){
  53. int rr = rand()%n;
  54. s.PB(allv[rr][i]);
  55. }
  56. if(alls.find(s)==alls.end()){
  57. return make_pair(true,s);
  58. }
  59. else return make_pair(false,"");
  60. }
  61.  
  62. int main(){
  63. srand(time(0));
  64. int t;
  65. scanf("%d",&t);
  66. FREP(cs,1,t){
  67. alls.clear();
  68. allv.clear();
  69. int N,L;
  70. scanf("%d %d",&N,&L);
  71. FREP(i,1,N){
  72. string s;
  73. cin>>s;
  74. alls.insert(s);
  75. allv.PB(s);
  76. }
  77. printf("Case #%d: ",cs);
  78. int f = 0;
  79. FREP(i,1,100000){
  80. pair<bool,string>my = getstr(L,N);
  81. if(my.first==true){
  82. cout<<my.second<<"\n";
  83. f=1;
  84. break;
  85. }
  86. }
  87. if(f)continue;
  88. else printf("-\n");
  89. }
  90. return 0;
  91. }
Runtime error #stdin #stdout 0s 4188KB
stdin
Standard input is empty
stdout
Standard output is empty