口糊的题,网上没有,std 不保证正确性。
题意应该比较清晰,标准的大模拟,不知道有没有人大概看过题干,大致的思路就是从每一帧的角度去考虑,类比 Unity3D 中的 Update()
函数,并且对每个玩家分别模拟其每一帧,然后需要注意亿点细节,码量大概 12+K。
思路一致,但只有移动可以减少很大一部分码量。
将所有情况都完善地符合要求地考虑到,也就是程序是正确的,同时当一方胜利时直接结束游戏不去考虑后面的内容,朴素地实现这个程序即可。
可以发现大量雪球可能会被同时丢出来,所以只需要将重复的雪球合成为同一个,判定时将计算后的真实伤害翻对应倍即可。
xxxxxxxxxx
3671
2
3
4
5
6
7
8/******************************
9abbr
10px/py => position x/y
11atk => Attack
12def => defence
13dir => direction
14vel => velocity
15dur => durability
16txxx => transform xxx
17opt/oper => operator
18ins => instant
19day => delayed
20******************************/
21
22
23
24
25
26
27
28
29
30
31using namespace std;
32
33mt19937 rnd(random_device{}());
34int rndd(int l, int r){return rnd() % (r - l + 1) + l;}
35
36typedef unsigned int uint;
37typedef unsigned long long unll;
38typedef long long ll;
39
40int height, width;
41vector < char > oper_ins[5];
42vector < char > oper_day[5];
43int dx[10] = {0, 1, 0, -1, 0};
44int dy[10] = {0, 0, 1, 0, -1};
45int ddx[10] = {0, 1, 1, 1, 0, 0, -1, -1, -1};
46int ddy[10] = {0, -1, 0, 1, -1, 1, -1, 0, 1};
47
48enum Job{soldier = 1, assassin, tank, magician, priest};
49string player_name[5] = {"", "tsawke", "sssmzy", "zpair", "cc0000"};
50string job_name[6] = {"", "soldier", "assassin", "tank", "magician", "priest"};
51int tplayer(string);
52int tfps(string);
53Job tjob(string);
54void Attack(int, int, int = 1);
55void pResults(void);
56void JudgeWin(int);
57void JudgeDie(void);
58void MakeDayOPT(int);
59void MakeInsOPT(int);
60
61struct Player{
62 int px, py;
63 int HP, maxHP;
64 int atk, def;
65 int dir;
66 int vel;
67 int dur;
68 int fps;
69 Job job;
70 bool team;
71 void Player_Init(int, int, int, int, int, int, Job);
72 void Init(int, int, int);
73 void Desc(void){
74 cout << job << "_" << team << endl;
75 printf("Player Status:\nx = %d, y = %d\nHP = %d, mHP = %d\natk = %d, def = %d\n, dir = %d, vel = %d, dur = %d\nfps = %d\n\n",
76 px, py, HP, maxHP, atk, def, dir, vel, dur, fps);
77 }
78}player[5];
79
80int main(){
81 freopen("snewbal1l.in", "r", stdin);
82 freopen("snewbal1l.out", "w", stdout);
83 ios::sync_with_stdio(false);
84 player[1].team = player[2].team = false;
85 player[3].team = player[4].team = true;
86 for(int i = 1; i <= 4; ++i){
87 string name, fps;
88 cin >> name >> fps;
89 player[tplayer(name)].fps = tfps(fps);
90 }
91 cin >> height >> width;
92 for(int i = 1; i <= 4; ++i){
93 string name, job;
94 cin >> name >> job;
95 int namep = tplayer(name);
96 Job jobp = tjob(job);
97 switch(jobp){
98 case soldier:
99 player[namep].Player_Init(SOLDIER, jobp); break;
100 case assassin:
101 player[namep].Player_Init(ASSASSIN, jobp); break;
102 case tank:
103 player[namep].Player_Init(TANK, jobp); break;
104 case magician:
105 player[namep].Player_Init(MAGICIAN, jobp); break;
106 case priest:
107 player[namep].Player_Init(PRIEST, jobp); break;
108 }
109 }
110 for(int i = 1; i <= 4; ++i){
111 string name; int px, py, dir;
112 cin >> name;
113 cin >> px >> py >> dir;
114 player[tplayer(name)].Init(px, py, dir);
115 }
116 while(true){
117 int time;
118 cin >> time;
119 if(!~time){
120 printf("No one is the winner!\n-1\n");
121 pResults();
122 }
123 vector < int > ord;
124 for(int i = 1; i <= 4; ++i){
125 oper_ins[i].clear();
126 oper_day[i].clear();
127 string name, opt;
128 cin >> name >> opt;
129 int pname = tplayer(name);
130 for(auto i : opt){
131 if(i == 'w' || i == 'a' || i == 's' || i == 'd' || i == '*' || i == '+')oper_day[pname].push_back(i);
132 else oper_ins[pname].push_back(i);
133 }
134 MakeInsOPT(pname);
135 ord.push_back(pname);
136 }
137 JudgeWin(time);
138 for(auto o : ord)MakeDayOPT(o), JudgeWin(time);
139 }
140 // fprintf(stderr, "Time: %.6lf\n", (double)clock() / CLOCKS_PER_SEC);
141 return 0;
142}
143struct Snb{
144 int x, y;
145 int dir;
146 int atk;
147 int v;
148 int cnt;
149 Snb(int x, int y, int dir, int atk, int v):x(x), y(y), dir(dir), atk(atk), v(v), cnt(1){;}
150 Snb(void) = default;
151};
152void MakeDayOPT(int playr){
153 int ori_def[5];
154 int exdef[5];
155 int def_fps[5];
156 memset(def_fps, 0, sizeof(def_fps));
157 vector < Snb > snb;
158 vector < char > move[5];
159 for(int j = 1; j <= 4; ++j){
160 ori_def[j] = PJ.def;
161 exdef[j] = int(floor((double)PJ.def * 1.2));
162 bool pushed(false);
163 for(auto i : oper_day[j]){
164 switch(i){
165 case '*':
166 if(!pushed)
167 snb.push_back(Snb(PP.px, PP.py, PP.dir, PP.atk, PP.vel)),
168 pushed = true;
169 else
170 snb.back().cnt++;
171 break;
172 case '+':
173 def_fps[j] = PP.dur;
174 break;
175 default:
176 move[j].push_back(i);
177 break;
178 }
179 }
180 reverse(move[j].begin(), move[j].end());
181 }
182 for(int i = 1; i <= PP.fps; ++i){
183 for(int j = 1; j <= 4; ++j)
184 if(def_fps[j]-- > 0)PJ.def = exdef[j];
185 else PJ.def = ori_def[j];
186 for(auto &s : snb){
187 switch(s.dir){
188 case 1: s.x -= s.v; break;
189 case 2: s.y += s.v; break;
190 case 3: s.x += s.v; break;
191 case 4: s.y -= s.v; break;
192 }
193 }
194 for(int j = 1; j <= 4; ++j){
195 if(move[j].empty())continue;
196 switch(move[j].back()){
197 case 'w': PJ.px -= 1; break;
198 case 'd': PJ.py += 1; break;
199 case 's': PJ.px += 1; break;
200 case 'a': PJ.py -= 1; break;
201 }
202 move[j].pop_back();
203 }
204 for(int j = 1; j <= 4; ++j)
205 for(auto s : snb)
206 if(PJ.px == s.x && PJ.py == s.y)
207 Attack(s.atk, j, s.cnt);
208 }
209 for(int j = 1; j <= 4; ++j)PJ.def = ori_def[j];
210 JudgeDie();
211}
212void MakeInsOPT(int playr){
213 for(auto i : oper_ins[playr]){
214 switch(i){
215 case 't':{
216 if(PP.dir <= 3)PP.dir++;
217 else PP.dir = 1;
218 break;
219 }
220 case 'f':{
221 switch(PP.job){
222 case soldier:{
223 for(int i = 1; i <= 8; ++i)
224 for(int j = 1; j <= 4; ++j)
225 if(PJ.HP > 0 && PJ.px == PP.px + ddx[i] && PJ.py == PP.py + ddy[i])
226 Attack(PP.atk * 3, j);
227 break;
228 }
229 case assassin:{
230 for(int j = 1; j <= 4; ++j)
231 if(
232 PJ.HP > 0 &&
233 (
234 (PP.dir == 1 && PJ.px < PP.px && PJ.px >= PP.px - 2 && PJ.py == PP.py) ||
235 (PP.dir == 3 && PJ.px > PP.px && PJ.px <= PP.px + 2 && PJ.py == PP.py) ||
236 (PP.dir == 2 && PJ.py > PP.py && PJ.py <= PP.py + 2 && PJ.px == PP.px) ||
237 (PP.dir == 4 && PJ.py < PP.py && PJ.py >= PP.py - 2 && PJ.px == PP.px)
238 )
239 )
240 Attack(PP.atk * floor((PJ.maxHP - PJ.HP) * 1.00 / PJ.maxHP), j);
241 break;
242 }
243 case magician:{
244 for(int j = 1; j <= 4; ++j)
245 if(PJ.team != PP.team)
246 PJ.def = floor((double)PJ.def * 0.8);
247 break;
248 }
249 case priest:{
250 for(int j = 1; j <= 4; ++j)
251 if(PJ.team == PP.team && PJ.HP > 0)
252 PJ.HP = min(PJ.maxHP, int(floor((double)PJ.HP * 1.5)));
253 break;
254 }
255 default: break;
256 }
257 break;
258 }
259 case 'g':{
260 switch(PP.job){
261 case soldier:{
262 if((double)PP.HP < (double)PP.maxHP * 0.1){
263 for(int j = 1; j <= 4; ++j)
264 if(PJ.team == PP.team)
265 PJ.atk = int(floor((double)PJ.atk * 1.2));
266 PP.fps = int(floor((double)PP.fps * 0.8));
267 }else
268 PP.HP = int(floor((double)PP.HP * 0.7));
269 break;
270 }
271 case assassin:{
272 PP.HP = int(floor((double)PP.HP * 0.9));
273 switch(PP.dir){
274 case 1: PP.px -= 3; break;
275 case 3: PP.px += 3; break;
276 case 2: PP.py += 3; break;
277 case 4: PP.py -= 3; break;
278 }
279 break;
280 }
281 case magician:{
282 for(int j = 1; j <= 4; ++j)
283 if(PJ.team == PP.team)
284 PJ.atk = int(floor((double)PJ.atk * 1.2));
285 break;
286 }
287 case priest:{
288 for(int j = 1; j <= 4; ++j)
289 if(PJ.team == PP.team)
290 PJ.def = floor((double)PJ.def * 1.2);
291 break;
292 }
293 default: break;
294 }
295 break;
296 }
297 case 'x':{
298 bool died(false);
299 for(int j = 1; j <= 4; ++j)
300 if(PJ.team != PP.team && PJ.HP > 0)
301 if((double)PJ.HP < (double)PJ.maxHP * 0.1){
302 PJ.HP = -1;
303 died = true;
304 }
305 if(!died)
306 PP.HP = int(floor((double)PP.HP * 0.6));
307 break;
308 }
309 case 'p':{
310 for(int j = 1; j <= 4; ++j)
311 if(PJ.team == PP.team)
312 PJ.fps = int(floor((double)PJ.fps * 0.8));
313 else
314 PJ.fps = int(floor((double)PJ.fps * 1.2));
315 break;
316 }
317 }
318 }
319}
320void JudgeDie(void){
321 for(int j = 1; j <= 4; ++j){
322 if(PJ.px <= 0 || PJ.py <= 0 || PJ.px > height || PJ.py > width)
323 PJ.HP = -1;
324 }
325}
326void JudgeWin(int time){
327 if(player[1].HP <= 0 && player[2].HP <= 0){
328 printf("zpair & cc0000 are the winners!\n%d\n", time);
329 return pResults();
330 }
331 if(player[3].HP <= 0 && player[4].HP <= 0){
332 printf("tsawke & sssmzy are the winners!\n%d\n", time);
333 return pResults();
334 }
335}
336void Attack(int atk, int playr, int cnt){
337 // printf("ATTACK: %d, to %d\n", atk, playr);
338 if(PP.HP <= 0)return;
339 PP.HP -= max(1, atk - PP.def) * cnt;
340}
341void pResults(void){
342 for(int i = 1; i <= 4; ++i)printf("%d%c", player[i].HP > 0 ? player[i].HP : 0, i == 4 ? '\n' : ' ');
343 for(int i = 1; i <= 4; ++i)printf("%d%c", player[i].fps, i == 4 ? '\n' : ' ');
344 exit(0);
345}
346int tfps(string fps){
347 int ret(0);
348 for(auto i : fps){
349 if(isdigit(i)){
350 ret *= 10;
351 ret += i - '0';
352 }
353 }
354 return ret;
355}
356Job tjob(string job){for(int i = 1; i <= 5; ++i)if(!job_name[i].compare(job))return (Job)i; return (Job)1;}
357int tplayer(string name){for(int i = 1; i <= 4; ++i)if(!player_name[i].compare(name))return i; return -1;}
358void Player::Init(int px, int py, int dir){
359 this->px = px, this->py = py;
360 this->dir = dir;
361}
362void Player::Player_Init(int HP, int maxHP, int atk, int def, int vel, int dur, Job job){
363 this->HP = HP, this->maxHP = maxHP,
364 this->atk = atk, this->def = def,
365 this->vel = vel, this->dur = dur;
366 this->job = job;
367}
因为 LemonLime 似乎测评不了 IO 交互题,所以在 Luogu 配置了一道题。
这纯纯一道黄题,把所有可能的数字都询问一遍,获得 md5 值之后直接放到 map 里面,然后对于每个 md5 输出其映射的明文。
xxxxxxxxxx
581
2
3
4
5
6
7
8using namespace std;
9
10mt19937 rnd(random_device{}());
11int rndd(int l, int r){return rnd() % (r - l + 1) + l;}
12
13typedef unsigned int uint;
14typedef unsigned long long unll;
15typedef long long ll;
16
17template<typename T = int>
18inline T read(void);
19
20int N;
21map < string, string > idx;
22string str[11000];
23int main(){
24 cin >> N;
25 for(int i = 1; i <= N; ++i)cin >> str[i];
26 for(int i = 0; i <= 9999; ++i){
27 char* tmp = new char[10];
28 sprintf(tmp, "%d", i);
29 string tmps(tmp);
30 cout << tmps << endl;
31 string md5s;
32 cin >> md5s;
33 idx.insert(make_pair(md5s, tmps));
34 delete[] tmp;
35 }
36 printf("Completely Hacked!\n");fflush(stdout);
37 for(int i = 1; i <= N; ++i)cout << idx[str[i]] << endl;
38 // fprintf(stderr, "Time: %.6lf\n", (double)clock() / CLOCKS_PER_SEC);
39 return 0;
40}
41
42
43
44template<typename T>
45inline T read(void){
46 T ret(0);
47 short flag(1);
48 char c = getchar();
49 while(c != '-' && !isdigit(c))c = getchar();
50 if(c == '-')flag = -1, c = getchar();
51 while(isdigit(c)){
52 ret *= 10;
53 ret += int(c - '0');
54 c = getchar();
55 }
56 ret *= flag;
57 return ret;
58}
和上一题差不多,理解交互方式即可切掉。
xxxxxxxxxx
251
2
3using namespace std;
4
5extern std::string EncryptMD5(std::string);
6extern std::string HackLLQ(std::string);
7
8map < string, string > idx;
9bool inited(false);
10
11void Init(void){
12 for(int i = 0; i <= 9999; ++i){
13 char* tmp = new char[10];
14 sprintf(tmp, "%d", i);
15 string tmps(tmp);
16 string md5s = EncryptMD5(tmps);
17 idx.insert(make_pair(md5s, tmps));
18 delete[] tmp;
19 }
20}
21
22std::string HackLLQ(std::string md5){
23 if(!inited)Init(), inited = true;
24 return idx[md5];
25}
人类智慧,没题解。