QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#203467#2483. Roof EscapeDreamOn#WA 1ms6256kbC++232.6kb2023-10-06 17:39:372023-10-06 17:39:38

Judging History

你现在查看的是最新测评结果

  • [2023-10-06 17:39:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6256kb
  • [2023-10-06 17:39:37]
  • 提交

answer

#include <bits/stdc++.h>

#define MP(x, y) make_pair(x, y)
#define pii pair <int, int>

using namespace std;

const double eps = 1e-8;

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

#define Maxn 100005
int W, H, Sx, Sy, Ex, Ey;
double ans1, ans2, k, b;
vector <int> t[Maxn];

void calcLine() {
    if(Sx == Ex) k = 1926, b = Sx;
    else {
        k = (Sy - Ey) * 1.0 / (Sx - Ex);
        b = Sy - k * Sx;
    }
}

int main() {
    W = read(); H = read(); Sx = read(); Sy = read(); Ex = read(); Ey = read();
    ans1 = sqrt((Sx - Ex) * (Sx - Ex) + (Sy - Ey) * (Sy - Ey));
    for(int i = 1; i <= H / 2; ++i) { // Attention it's a (H/2, W/2) matrix!
        t[i].push_back(0);
        for(int j = 1; j <= W / 2; ++j) t[i].push_back(read());
    }

    calcLine();

    if(Sx > Ex) swap(Sx, Ex), swap(Sy, Ey);
    for(double x = Sx + 1, y; x <= Ex - 1; x += 2) {
        y = k * x + b;
        if(fabs((y / 2) - (int)(y / 2)) > eps) { // Edge
            int li = (ceil)(y / 2), lj = x / 2;
            int ri = li, rj = lj + 1;
            ans2 += fabs(t[li][lj] - t[ri][rj]);
            // cerr << "???" << endl;
        }
        else { // Point
            int ai = y / 2, aj = x / 2;
            int bi = ai, bj = aj + 1;
            int ci = ai + 1, cj = aj;
            int di = ai + 1, dj = aj + 1;
            int maxh = max(max(t[ai][aj], t[bi][bj]), max(t[ci][cj], t[di][dj]));
            if(k > 0) ans2 += (maxh - t[ai][aj]) + (maxh - t[di][dj]);
            else ans2 += (maxh - t[bi][bj]) + (maxh - t[ci][cj]);
            // cerr << "plog " << x << " " << y << " " << ans2 << " " << maxh << endl;
            // cerr << "qlog " << ai << " " << bi << " " << ci << " " << di << endl;
            // cerr << "elog " << aj << " " << bj << " " << cj << " " << dj << endl;
        }
    }

    if(Sy > Ey) swap(Sx, Ex), swap(Sy, Ey);

    // cerr << Sx << " " << Sy << " " << Ex << " " << Ey << endl;
    for(double y = Sy + 1, x; y <= Ey - 1; y += 2) {
        if(k == 1926) x = Sx;
        else x = (y - b) / k;
        // cerr << "!!!" << x << endl;
        if(fabs((x / 2) - (int)(x / 2)) > eps) { // Edge
            int ui = (ceil)(x / 2), uj = y / 2;
            int di = ui + 1, dj = uj;
            ans2 += fabs(t[ui][uj] - t[di][dj]);
            // cerr << "???" << endl;
        }
    }

    cout << fixed << setprecision(10);
    cout << ans1 + ans2 << endl;
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6256kb

input:

4 26 1 1 3 25
0 1
0 5
5 5
0 1
2 1
4 1
5 0
0 0
1 0
6 4
3 2
5 4
1 5

output:

42.0831891576

result:

wrong answer 1st numbers differ - expected: '53.08319', found: '42.08319', error = '0.20722'