https://www.cnblogs.com/lemonniforever/p/csp-j-Amazing-For-Oier.html
https://www.luogu.com.cn/blog/ak-ioi/sto-tnt-orz
https://www.luogu.com.cn/paste/iylqqi8h
https://lab.magiconch.com/homo/
https://www.cnblogs.com/lemonniforever/p/CQ-NOIp-magicer-and-mengbier.html
https://www.cnblogs.com/lemonniforever/p/csp-j-2022-mengbier-in-CQ.html
https://www.luogu.com/article/kxi9kr04
https://www.luogu.com/paste/7gqim2jh
https://blog.csdn.net/2201_75605164/article/details/133951800
#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
const int r = 18;
const int c = 30;
char ch, mp[r + 5][c + 5];
int x, y, t, nx, ny, cnt;
void print() {
for(int i = 1; i <= r; ++i) puts(mp[i] + 1);
cout << "score:" << cnt << endl;
}
void No() {
system("cls");
puts("GAME OVER!!!");
exit(0);
}
vector< pair<int, int> > v;
int main() {
srand(time(NULL));
memset(mp, '.', sizeof(mp));
for(int i = 1; i <= r; ++i) mp[i][c + 1] = 0;
nx = 1, ny = 4;
for(int i = 1; i <= 3; ++i) {
v.push_back(make_pair(1, i));
mp[1][i] = '#';
}
mp[nx][ny] = '@';
v.push_back(make_pair(nx, ny));
t = 20;
while(t--) {
do {
x = rand() % r + 1, y = rand() % c + 1;
} while(mp[x][y] != '.');
mp[x][y] = '$';
}
t = 40;
while(t--) {
do {
x = rand() % r + 1, y = rand() % c + 1;
} while(mp[x][y] != '.');
mp[x][y] = 'X';
}
t = 2;
while(t--) {
do {
x = rand() % r + 1, y = rand() % c + 1;
} while(mp[x][y] != '.');
mp[x][y] = '*';
}
print();
while(cnt < 50) {
ch = getch();
if(ch == 'w') {
if(nx > 1) {
mp[nx][ny] = '#';
--nx;
}
else No();
}
if(ch == 's') {
if(nx < r) {
mp[nx][ny] = '#';
++nx;
}
else No();
}
if(ch == 'a') {
if(ny > 1) {
mp[nx][ny] = '#';
--ny;
}
else No();
}
if(ch == 'd') {
if(ny < c) {
mp[nx][ny] = '#';
++ny;
}
else No();
}
if(mp[nx][ny] == '*') {
mp[nx][ny] = '.';
for(int i = 1; i <= r; ++i)
for(int j = 1; j <= c; ++j)
if(mp[i][j] == '*') {
nx = i, ny = j;
mp[i][j] = '.';
}
t = 2;
while(t--) {
do {
x = rand() % r + 1, y = rand() % c + 1;
} while(mp[x][y] != '.');
mp[x][y] = '*';
}
}
if(mp[nx][ny] == '$') {
++cnt;
mp[nx][ny] = '@';
v.push_back(make_pair(nx, ny));
do {
x = rand() % r + 1, y = rand() % c + 1;
} while(mp[x][y] != '.');
mp[x][y] = '$';
}
else if(mp[nx][ny] == 'X') No();
else {
for(int i = 1; i < v.size(); ++i)
if(v[i].first == nx && v[i].second == ny) {
No();
}
v.push_back(make_pair(nx, ny));
mp[v[0].first][v[0].second] = '.';
v.erase(v.begin());
mp[nx][ny] = '@';
}
system("cls");
print();
}
system("cls");
cout << "You win!!!" << endl;
return 0;
}