QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#670324#7758. PainterzhcmmmCompile Error//C++202.1kb2024-10-23 21:19:442024-10-23 21:19:44

Judging History

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

  • [2024-10-23 21:19:44]
  • 评测
  • [2024-10-23 21:19:44]
  • 提交

answer

using pii = std::pair<int, int>;
#define x first
#define y second
 
pii operator-(pii a, pii b) {
    return {a.x - b.x, a.y - b.y};
}
i64 operator*(pii a, pii b) {
    return 1ll * a.x * b.x + 1ll * a.y * b.y;
}
i64 dis2(pii a, pii b) {
    auto p = a - b;
    return p * p;
}
bool Mid(int a, int b, int c) {
    return a <= b and b <= c;
}
 
struct Draw {
    std::string op = "";
    pii p1 = {0, 0};
    char col = '.';
    virtual bool Inside(pii p) = 0; // 纯虚函数
};
struct Circle : public Draw {
    int r = 0;
    bool Inside(pii p) { // 多态
        return dis2(p1, p) <= 1ll * r * r;
    }
};
struct Rectangle : public Draw {
    pii p2 = {0, 0};
    bool Inside(pii p) { // 多态
        return Mid(p1.x, p.x, p2.x) and Mid(p1.y, p.y, p2.y);
    }
};
 
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    int qn;
    std::cin >> qn;
 
    std::vector<Draw *> a;
    for (int i = 0; i < qn; i++) {
        std::string op;
        std::cin >> op;
        if (op == "Circle") {
            Circle *p = new Circle();
            p->op = op;
            std::cin >> (p->p1.x) >> (p->p1.y);
            std::cin >> (p->r) >> (p->col);
 
            a.push_back(p);
        } else if (op == "Rectangle") {
            Rectangle *p = new Rectangle();
            p->op = op;
            std::cin >> (p->p1.x) >> (p->p1.y);
            std::cin >> (p->p2.x) >> (p->p2.y);
            std::cin >> (p->col);
 
            a.push_back(p);
        } else if (op == "Render") {
            pii p1, p2;
            std::cin >> p1.x >> p1.y;
            std::cin >> p2.x >> p2.y;
 
            std::vector res(p2.y - p1.y + 1, std::string(p2.x - p1.x + 1, '.'));
 
            for (auto p : a)
                for (int y = p1.y; y <= p2.y; y++)
                    for (int x = p1.x; x <= p2.x; x++)
                        if (p->Inside({x, y}))
                            res[y - p1.y][x - p1.x] = p->col;
 
            // 倒着输出
            for (int y = p2.y; y >= p1.y; y--) {
                std::cout << res[y - p1.y] << '\n';
            }
        }
    }
}

Details

answer.code:1:18: error: ‘pair’ in namespace ‘std’ does not name a template type
    1 | using pii = std::pair<int, int>;
      |                  ^~~~
answer.code:1:1: note: ‘std::pair’ is defined in header ‘<utility>’; did you forget to ‘#include <utility>’?
  +++ |+#include <utility>
    1 | using pii = std::pair<int, int>;
answer.code:5:1: error: ‘pii’ does not name a type
    5 | pii operator-(pii a, pii b) {
      | ^~~
answer.code:8:1: error: ‘i64’ does not name a type
    8 | i64 operator*(pii a, pii b) {
      | ^~~
answer.code:11:1: error: ‘i64’ does not name a type
   11 | i64 dis2(pii a, pii b) {
      | ^~~
answer.code:20:10: error: ‘string’ in namespace ‘std’ does not name a type
   20 |     std::string op = "";
      |          ^~~~~~
answer.code:1:1: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’?
  +++ |+#include <string>
    1 | using pii = std::pair<int, int>;
answer.code:21:5: error: ‘pii’ does not name a type
   21 |     pii p1 = {0, 0};
      |     ^~~
answer.code:23:25: error: ‘pii’ has not been declared
   23 |     virtual bool Inside(pii p) = 0; // 纯虚函数
      |                         ^~~
answer.code:27:17: error: ‘pii’ has not been declared
   27 |     bool Inside(pii p) { // 多态
      |                 ^~~
answer.code: In member function ‘virtual bool Circle::Inside(int)’:
answer.code:28:21: error: ‘p1’ was not declared in this scope; did you mean ‘p’?
   28 |         return dis2(p1, p) <= 1ll * r * r;
      |                     ^~
      |                     p
answer.code:28:16: error: ‘dis2’ was not declared in this scope
   28 |         return dis2(p1, p) <= 1ll * r * r;
      |                ^~~~
answer.code: At global scope:
answer.code:32:5: error: ‘pii’ does not name a type
   32 |     pii p2 = {0, 0};
      |     ^~~
answer.code:33:17: error: ‘pii’ has not been declared
   33 |     bool Inside(pii p) { // 多态
      |                 ^~~
answer.code: In member function ‘virtual bool Rectangle::Inside(int)’:
answer.code:34:20: error: ‘p1’ was not declared in this scope; did you mean ‘p’?
   34 |         return Mid(p1.x, p.x, p2.x) and Mid(p1.y, p.y, p2.y);
      |                    ^~
      |                    p
answer.code:2:11: error: request for member ‘first’ in ‘p’, which is of non-class type ‘int’
    2 | #define x first
      |           ^~~~~
answer.code:34:28: note: in expansion of macro ‘x’
   34 |         return Mid(p1.x, p.x, p2.x) and Mid(p1.y, p.y, p2.y);
      |                            ^
answer.code:34:31: error: ‘p2’ was not declared in this scope; did you mean ‘p’?
   34 |         return Mid(p1.x, p.x, p2.x) and Mid(p1.y, p.y, p2.y);
      |                               ^~
      |                               p
answer.code:3:11: error: request for member ‘second’ in ‘p’, which is of non-class type ‘int’
    3 | #define y second
      |           ^~~~~~
answer.code:34:53: note: in expansion of macro ‘y’
   34 |         return Mid(p1.x, p.x, p2.x) and Mid(p1.y, p.y, p2.y);
      |                                                     ^
answer.code: In function ‘int main()’:
answer.code:39:10: error: ‘std::ios_base’ has not been declared
   39 |     std::ios_base::sync_with_stdio(false);
      |          ^~~~~~~~
answer.code:40:10: error: ‘cin’ is not a member of ‘std’
   40 |     std::cin.tie(nullptr);
      |          ^~~
answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
  +++ |+#include <iostream>
    1 | using pii = std::pair<int, int>;
answer.code:43:10: error: ‘cin’ is not a member of ‘std’
   43 |     std::cin >> qn;
      |          ^~~
answer.code:43:10: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
answer.code:45:10: error: ‘vector’ is not a member of ‘std’
   45 |     std::vector<Draw *> a;
      |          ^~~~~~
answer.code:1:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
  +++ |+#include <vector>
    1 | using pii = std::pair<int, int>;
answer.code:45:22: error: expected primary-expression before ‘*’ token
   45 |     std::vector<Draw *> a;
      |                      ^
answer.code:45:23: error: expected primary-expression before ‘>’ token
   45 |     std::vector<Draw *> a;
      |                       ^
answer.code:45:25: error: ‘a’ was not declared in this scope
   45 |     std::vector<Draw *> a;
      |                         ^
answer.code:47:14: error: ‘string’ is not a member of ‘std’
   47 |         std::string op;
      |              ^~~~~~
answer.code:47:14: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’?
answer.code:48:14: error: ‘cin’ is not a member of ‘std’
   48 |         std::cin >> op;
      |              ^~~
answer.code:48:14: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
answer.code:48:21: error: ‘op’ was not declared in this scope
   4...