今天试了一下第四题,正在我为了样例通过而沾沾自喜的时候,提交的结果是错误,虽然很emo,但也知道,光靠模拟答对的第四题必然没有含金量,问了很厉害的学长,学长说替罪羊树乱搞,我暂时还不知道替罪羊树是什么,还有待努力,把这个只能过样例的代码放这儿吧,等以后我真的做出来这道题,我再来替换他。
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long LL;
int sss, m, k, d;
//待删除
map<int, int> dk;
//光线
typedef pair<LL, LL> PLL;
struct ray {
int direction;
int rank;
double a;
};
ray r[N];
int rr = 1;
map<PLL, int> mp;
//添加反射面
void add(LL x1, LL y1, LL x2, LL y2, int k, double a, int rr) {
r[rr].direction = (y2 - y1) / (x2 - x1);
r[rr].rank = k;
r[rr].a = a;
if (r[rr].direction == 1) {
if (x1 < x2)
for (LL i = x1 + 1, j = y1 + 1; i < x2, j < y2; i++, j++) {
mp[{i, j}] = rr;
}
else {
for (LL i = x2 + 1, j = y2 + 1; i < x1, j < y1; i++, j++) {
mp[{i, j}] = rr;
}
}
}
else {
if (x1 < x2) {
for (LL i = x1 + 1, j = y1 - 1; i<x2, j>y2; i++, j--) {
mp[{i, j}] = rr;
}
}
else {
for (LL i = x2 + 1, j = y2 - 1; i<x1, j>y1; i++, j--) {
mp[{i, j}] = rr;
}
}
}
}
//光线反射(光,反射面)
typedef pair<int, int> PII;
map<PII, int> rp;
//添加光线反射,对4取余
void add2() {
rp[{2, -1}] = 1;
rp[{0, 1}] = 1;
rp[{0, -1}] = 3;
rp[{2, 1}] = 3;
rp[{3, -1}] = 4;
rp[{1, -1}] = 2;
rp[{1, 1}] = 4;
rp[{3, 1}] = 2;
}
int main() {
add2();
LL x1, x2, y1, y2, t;
double a, I;
cin >> m;
for (int i = 1; i <= m; i++) {
cin >> sss;
if (sss == 1) {
cin >> x1 >> y1 >> x2 >> y2 >> a;
add(x1, y1, x2, y2, i, a, rr);
rr++;
}
else if (sss == 2) {
cin >> k;
dk[k]++;
}
else {
LL X, Y;
cin >> X >> Y >> d >> I >> t;
while (t--) {
if (I < 1)break;
d %= 4;
if (d == 0) X++;
else if (d == 1)Y++;
else if (d == 2)X--;
else if (d == 3)Y--;
if (mp.count({ X,Y }) != 0 && dk[mp[{X, Y}]] != 1) {
I *= r[mp[{X, Y}]].a;
d = rp[{d, r[mp[{X, Y}]].direction}];
}
}
if (I < 1)cout << "0 0 0" << endl;
else {
cout << X << " " << Y << " " << floor(I) << endl;
}
}
}
return 0;
}