QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#632207#7758. PainterREN5511WA 1ms3560kbC++142.3kb2024-10-12 12:56:472024-10-12 12:56:48

Judging History

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

  • [2024-10-12 12:56:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3560kb
  • [2024-10-12 12:56:47]
  • 提交

answer

#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
unordered_map<ll, unordered_map<ll, char>>mp;
struct ins
{
    string type;
    ll x1, x2, y1, y2,r;
    char tar;
};
vector<ins>ok;
void circle(ll x1, ll x2, ll y1, ll y2,ll x, ll y, ll r, char tar) {
    for (int i = y1; i <= y2; i++) {
        for (int j = x1; j <=x2; j++) {
            if ((i - y) * (i - y) + (j -x) * (j - x) <= r * r) {
                mp[i][j] = tar;
            }
            else {
                mp[i][j] = '.';
            }
        }
    }
}
void rectangle(ll x1,ll x2,ll y1,ll y2,char tar) {
    for (int i = y1; i <= y2; i++) {
        for (int j = x1; j <= x2; j++) {
            mp[i][j] = tar;
        }
    }
}
void render() {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    for (auto now : ok) {
        ll xl, xr, yl, yr, x, y, r;
        if (now.type == "Circle") {
            xl = max(x1, now.x1 - now.r);
            xr = min(x2, now.x1 + now.r);
            yl = max(y1, now.y1 - now.r);
            yr = min(y2, now.y1 + now.r);
            circle(xl, xr, yl, yr, now.x1, now.y1, now.r, now.tar);
        }
        else {
            xl = max(x1, now.x1);
            xr = min(x2, now.x2);
            yl = max(y1, now.y1);
            yr = min(y2, now.y2);
            rectangle(xl, xr, yl, yr, now.tar);
        }
    }
    for (int i = y2; i >= y1; i--) {
        for (int j = x2; j >= x1; j--) {
            if (mp[i][j] == 0) {
                mp[i][j] = '.';
            }
            cout << mp[i][j];
        }
        cout << "\n";
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    while (n--) {
        string what;
        cin >> what;
        if (what == "Circle") {
            ll x, y, r;
            char tar;
            cin >> x >> y >> r >> tar;
            ok.push_back({ what,x,0,y,0,r,tar});
        }
        else if (what == "Rectangle") {
            ll x1, y1, x2, y2;
            char tar;
            cin >> x1 >> y1 >> x2 >> y2 >> tar;
            ok.push_back({ what,x1,x2,y1,y2,0,tar});
        }
        else {
            render();
        }
    }
    return 0;
}

詳細信息

Test #1:

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

input:

7
Circle 0 0 5 *
Circle -2 2 1 @
Circle 2 2 1 @
Rectangle 0 -1 0 0 ^
Rectangle -2 -2 2 -2 _
Render -5 -5 5 5
Render -1 0 1 2

output:

.....*.....
..*******..
.*.@.*.@.*.
.*@@@*@@@*.
.*.@.*.@.*.
*****^*****
.****^****.
.**_____**.
.*********.
..*******..
.....*.....
@*@
.*.
*^*

result:

wrong answer 3rd lines differ - expected: '.**@***@**.', found: '.*.@.*.@.*.'