Advertisement
erfanul007

UVa 11804

Jan 24th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int > pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define sc scanf
  14. #define pf printf
  15. #define sci(n) scanf("%d",&n)
  16. #define scl(n) scanf("%lld",&n)
  17. #define scf(n) scanf("%lf",&n)
  18. #define scs(s) scanf("%s",s)
  19. #define pfi(n) printf("%d",n)
  20. #define pfl(n) printf("%lld",n)
  21. #define pff(n) cout<<n
  22. #define line printf("\n")
  23. #define spc printf(" ")
  24. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  25. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  26. #define cspf(i) printf("Case %d:", i)
  27. #define pb push_back
  28. #define mp make_pair
  29. #define ff first
  30. #define ss second
  31. #define all(v) v.begin(),v.end()
  32. #define rall(v) v.rbegin(),v.rend()
  33. #define read() freopen("input.txt", "r", stdin)
  34. #define write() freopen("output.txt", "w", stdout)
  35. /// Constants
  36. #define eps 1e-9
  37. #define PI acos(-1.0) // 3.1415926535897932
  38.  
  39. int main()
  40. {
  41. read();
  42. write();
  43. int n; sci(n);
  44. loop(j,1,n){
  45. vector< pair< pair<int,int>, string > > player(10);
  46. int x,y;
  47. string nm;
  48. loop(i,0,9){
  49. cin>>nm;
  50. player[i].second=nm;
  51. cin>>x>>y;
  52. player[i].first.first=x;
  53. player[i].first.second=y;
  54. }
  55. sort(player.rbegin(),player.rend());
  56. int k=5;
  57. rloop(i,4,0){
  58. if(player[5].first.first==player[i].first.first)
  59. k=i;
  60. else
  61. break;
  62. }
  63. int l=4;
  64. loop(i,5,9){
  65. if(player[4].first.first==player[i].first.first)
  66. l=i;
  67. else
  68. break;
  69. }
  70. if(l>=k)
  71. sort(player.begin()+k,player.begin()+(l+1));
  72.  
  73. vector<string>attck,diff;
  74.  
  75. loop(i,0,4){
  76. attck.push_back(player[i].second);
  77. }
  78. loop(i,5,9){
  79. diff.push_back(player[i].second);
  80. }
  81. sort(all(attck));
  82. sort(all(diff));
  83. cspf(j);
  84. line;
  85. pf("(");
  86. loop(i,0,4){
  87. cout<<attck[i];
  88. if(i<4) pf(", ");
  89. }
  90. pf(")\n(");
  91. loop(i,0,4){
  92. cout<<diff[i];
  93. if(i<4) pf(", ");
  94. }
  95. pf(")\n");
  96. }
  97. return 0;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement