답안 #382494

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
382494 2021-03-27T12:49:30 Z VEGAnn Pastiri (COI20_pastiri) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
#define PB push_back
#define pll pair<ll,ll>
#define M make_pair
#define ld long double
#define i2 array<int,2>
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const ll N = 100100;
ifstream in,ro,uo;
ofstream res;
string score;
vector<i2> jury, user, vc;
int a, b, c, d;

void term() {
    in.close();
    ro.close();
    uo.close();
    res.close();
    exit(0);
}

void BAD(const char *msg) {
    res<<"0\n"<<msg;
    term();
}

void OK() {
    res<<score<<"\nOK";
    term();
}

int area(i2 x, i2 y, i2 z){
    return (x[0] - y[0]) * (x[1] - z[1]) - (x[1] - y[1]) * (x[0] - z[0]);
}

int calc(vector<i2> &lst){
    int res = 0;

    for (int i = 0; i < sz(lst); i++)
        res += area({0, 0}, lst[i], lst[(i + 1) % sz(lst)]);

    return abs(res);
}

int main(int argc,char** argv) {
    if (argc!=5) return -1;
    in.open(argv[1]);
    ro.open(argv[2]);
    uo.open(argv[3]);
    res.open("$result$.txt");
    score=argv[4];

    int x, y;

    while (ro >> x >> y){
        jury.PB({x, y});
    }

    while (uo >> x >> y){
        user.PB({x, y});
        vc.PB({x, y});
    }

    if (sz(user) != sz(jury))
        BAD("в многоугольнике неправильное число вершин");

    sort(all(vc));
    vc.resize(unique(all(vc)) - vc.begin());

    if (sz(vc) < sz(user))
        BAD("в многоугольнике есть одинаковые точки");

    in >> a >> b >> c >> d;

    int n = sz(jury);

    for (int i = 0; i < n; i++){
        int nt = (i + 1) % n;

        int dx = user[i][0] - user[nt][0];
        int dy = user[i][1] - user[nt][1];

        if (abs(dx) > 1 || abs(dy) > 1)
            BAD("в многоугольнике есть неправильная сторона (не a, b, c, d)");

        if (dx == 0){
            b--;
        } else if (dy == 0){
            a--;
        } else {
            if ((dx > 0 && dy > 0) ||
                (dx < 0 && dy < 0))
                c--;
            else d--;
        }
    }

    if (a != 0 || b != 0 || c != 0 || d != 0)
        BAD("неправильный набор сторон");

    if (calc(jury) != calc(user))
        BAD("неправильная площадь");
    else OK();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -