2019沈阳网选——模拟

Posted love-fromatoz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2019沈阳网选——模拟相关的知识,希望对你有一定的参考价值。

  1 #include <bits/stdc++.h>
  2 using namespace std;
  3 
  4 struct Node
  5     string name;
  6     int straight;
  7     pair<int,int> four;
  8     pair<int,int> full;
  9     pair<int,int> three;
 10     pair<pair<int,int>,int> twopair;
 11     pair<int,int> pairr;
 12     int handcard;
 13 a[100005];
 14 
 15 bool cmp(Node a,Node b)
 16     if(a.straight == b.straight)
 17         if(a.four.first == b.four.first)
 18             if(a.four.second == b.four.second)
 19                 if(a.full.first == b.full.first)
 20                     if(a.full.second == b.full.second)
 21                         if(a.three.first == b.three.first)
 22                             if(a.three.second == b.three.second)
 23                                 if(a.twopair.first.first == b.twopair.first.first)
 24                                     if(a.twopair.first.second == b.twopair.first.second)
 25                                         if(a.twopair.second == b.twopair.second)
 26                                             if(a.pairr.first == b.pairr.first)
 27                                                 if(a.pairr.second == b.pairr.second)
 28                                                     if(a.handcard == b.handcard)
 29                                                         return a.name < b.name;
 30                                                     
 31                                                     return a.handcard > b.handcard;
 32                                                 
 33                                                 return a.pairr.second > b.pairr.second;
 34                                             
 35                                             return a.pairr.first > b.pairr.first;
 36                                         
 37                                         return a.twopair.second > b.twopair.second;
 38                                     
 39                                     return a.twopair.first.second > b.twopair.first.second;
 40                                 
 41                                 return a.twopair.first.first > b.twopair.first.first;
 42                             
 43                             return a.three.second > b.three.second;
 44                         
 45                         return a.three.first > b.three.first;
 46                     
 47                     return a.full.second > b.full.second;
 48                 
 49                 return a.full.first > b.full.first;
 50             
 51             return a.four.second > b.four.second;
 52         
 53         return a.four.first > b.four.first; ;
 54     
 55     return a.straight > b.straight;
 56 
 57 
 58 
 59 int n;
 60 int main()
 61 
 62     while(~scanf("%d",&n))
 63         for(int ii = 0;ii < n;ii ++)
 64             cin >> a[ii].name;
 65             a[ii].straight = -1;
 66             a[ii].four = make_pair(-1,-1);
 67             a[ii].full = make_pair(-1,-1);
 68             a[ii].three = make_pair(-1,-1);
 69             a[ii].twopair = make_pair(make_pair(-1,-1),-1);
 70             a[ii].pairr = make_pair(-1,-1);
 71             a[ii].handcard = -1;
 72             string p;cin >> p;
 73             int vis[17];
 74             memset(vis,0,sizeof(vis));
 75             for(int j = 0;j < p.size();j ++)
 76                 if(p[j] == 1)vis[10] ++;
 77                 if(p[j] == 0)continue;
 78                 if(p[j] == A)vis[14] ++;vis[1] ++;
 79                 if(p[j] == J)vis[11] ++;
 80                 if(p[j] == Q)vis[12] ++;
 81                 if(p[j] == K)vis[13] ++;
 82                 if(p[j] >= 2 && p[j] <= 9)
 83                     vis[p[j] - 0] ++;
 84                 
 85             
 86 
 87             for(int i = 1;i <= 10;i ++)///str
 88                 if(vis[i] && vis[i+1] && vis[i+2] && vis[i+3] && vis[i+4])
 89                     a[ii].straight = i;break;
 90                 
 91             
 92             if(a[ii].straight != -1)continue;
 93 
 94             for(int i = 1;i < 14;i ++)///four
 95                 if(vis[i] == 4)
 96                     a[ii].four.first = i;break;
 97                 
 98             
 99             for(int i = 1;i < 14;i ++)
100                 if(vis[i] == 1)
101                     a[ii].four.second = i;break;
102                 
103             
104             if(a[ii].four.second != -1 && a[ii].four.first != -1)continue;
105             elsea[ii].four = make_pair(-1,-1);
106 
107             for(int i = 1;i < 14;i ++)///full
108                 if(vis[i] == 3)
109                     a[ii].full.first = i;break;
110                 
111             
112             for(int i = 1;i < 14;i ++)
113                 if(vis[i] == 2)
114                     a[ii].full.second = i;break;
115                 
116             
117             if(a[ii].full.second == -1 || a[ii].full.first == -1)a[ii].full = make_pair(-1,-1);
118             elsecontinue;
119 
120             for(int i = 1;i < 14;i ++)///three
121                 if(vis[i] == 3)
122                     a[ii].three.first = i;break;
123                 
124             
125             int cnt = 0;
126             for(int i = 1;i < 14;i ++)
127                 if(vis[i] == 1)
128                     cnt += i;
129                 
130             
131             a[ii].three.second = cnt;
132             if(a[ii].three.second != -1 && a[ii].three.first != -1)continue;
133             elsea[ii].three = make_pair(-1,-1);
134 
135             cnt = 0;int sum = 0;
136             for(int i = 13;i >= 1;i --)///two p
137                 if(vis[i] == 2)
138                     if(a[ii].twopair.first.first != -1)
139                         cnt ++;a[ii].twopair.first.second = i;
140                     
141                     else a[ii].twopair.first.first = i;cnt ++;
142                 
143                 else if(vis[i] == 1)sum += i;
144             
145             if(cnt == 2)a[ii].twopair.second = sum;continue;
146             elsea[ii].twopair = make_pair(make_pair(-1,-1),-1);
147 
148             sum = 0;
149             for(int i = 13;i >= 1;i --)///pair
150                 if(vis[i] == 2)
151                     a[ii].pairr.first = i;
152                 
153                 else if(vis[i] == 1)
154                     sum += i;
155                 
156             
157             if(a[ii].pairr.first != -1)a[ii].pairr.second = sum;continue;
158             elsea[ii].pairr = make_pair(-1,-1);
159 
160             sum = 0;
161             for(int i = 13;i >= 1;i --)///hand
162                 if(vis[i] == 1)
163                     sum += i;
164                 
165             
166             a[ii].handcard = sum;
167         
168         for(int i = 0;i < n;i ++)
169             cout << a[i].name + " :" << endl;
170             cout << "str : " << a[i].straight << endl;
171             cout << "four : " << a[i].four.first << " " << a[i].four.second << endl;
172             cout << "full : " << a[i].full.first << " " << a[i].full.second << endl;
173             cout << "three : " << a[i].three.first << " " << a[i].three.second << endl;
174             cout << "twopa : " << a[i].twopair.first.first << " " << a[i].twopair.first.second << " " << a[i].twopair.second << endl;
175             cout << "pair : " << a[i].pairr.first << " " << a[i].pairr.second << endl;
176             cout << "hand : " << a[i].handcard << endl;
177         
178         sort(a,a + n,cmp);
179         for(int i = 0;i < n;i ++)
180             cout << a[i].name << endl;
181         
182     
183     return 0;
184 

 

以上是关于2019沈阳网选——模拟的主要内容,如果未能解决你的问题,请参考以下文章

2021 ICPC沈阳 J.Luggage Lock(bfs,模拟)

ICPC2018沈阳网络赛 Lattice's basics in digital electronics(模拟)

ACM-ICPC 2018 沈阳赛区网络预赛-I模拟题啊!!!

ACM-ICPC 2018 沈阳赛区网络预赛 I. Lattice's basics in digital electronics 阅读题加模拟题

CCPC2016沈阳站

最完整的台达PLC培训教程(沈阳工大)学习笔记1