답안 #364766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
364766 2021-02-10T01:08:27 Z ijxjdjd The Forest of Fangorn (CEOI14_fangorn) C++14
0 / 100
3 ms 492 KB
#include <bits/stdc++.h>
#define FR(i, N) for (int i = 0; i < int(N); i++)
#define all(x) begin(x), end(x)

using namespace std;

using ll = long long;

int N, M;
const int MAXN = 2000;
const int MAXM = 10000;
struct Point {
    ll x, y;
    void print() {
        cerr << x << " " << y << endl;
    }
};
Point start;
int bad[MAXM];
Point pos[MAXN];
Point cmps[MAXM];
void solve(int n) {
    FR(i, N) {
        if (i != n) {
            pos[i].x -= pos[n].x;
            pos[i].y -= pos[n].y;
        }
    }
    FR(i, M) {
        cmps[i].x -= pos[n].x;
        cmps[i].y -= pos[n].y;
    }
    start.x -= pos[n].x;
    start.y -= pos[n].y;
    vector<Point> pt;
    FR(i, N) {
        if (i != n) {
            pt.push_back({-pos[i].x, -pos[i].y});
        }
    }
    auto comp = [](const auto& lhs, const auto& rhs) {
        if (lhs.x == 0) {
            if (lhs.y > 0) {
                return true;
            }
            else {
                return rhs.x < 0;
            }
        }
        if (rhs.x == 0) {
            if (rhs.y > 0) {
                return false;
            }
            else {
                return lhs.x >= 0;
            }
        }
        if (lhs.x < 0 && rhs.x > 0) {
            return false;
        }
        if (lhs.x > 0 && rhs.x < 0) {
            return true;
        }
        if (lhs.x > 0) {
            return lhs.y * rhs.x - lhs.x * rhs.y > 0;
        }
        else {
            return lhs.y * (-rhs.x) - (-lhs.x) * rhs.y < 0;
        }
    };
    sort(all(pt), comp);
//    cout << n << endl;
//    for (auto& p : pt) {
//        p.print();
//    }
    if (comp(start, pt[0]) || comp(pt[pt.size()-1], start)) {
        FR(i, M) {
            if (comp(cmps[i], pt[0]) || comp(pt[pt.size()-1], cmps[i])) {
                bad[i]++;
            }
        }
    }
    else {
        for (int i = 1; i < pt.size(); i++) {
            if (comp(start, pt[i])) {
                FR(j, M) {
                    if (!comp(cmps[j], pt[i-1]) && comp(cmps[j], pt[i])) {
                        bad[j]++;
                    }
                }
                break;
            }
        }
    }
    FR(i, N) {
        if (i != n) {
            pos[i].x += pos[n].x;
            pos[i].y += pos[n].y;
        }
    }
    FR(i, M) {
        cmps[i].x += pos[n].x;
        cmps[i].y += pos[n].y;
    }
    start.x += pos[n].x;
    start.y += pos[n].y;
}
int main() {
    freopen("input.in", "r", stdin);
	cin.tie(0);
	cin.sync_with_stdio(0);
	int hg;
	cin >> hg >> hg;
	cin >> start.x >> start.y;
	cin >> M;
	FR(i, M) {
	    cin >> cmps[i].x >> cmps[i].y;
	}
	cin >> N;
	FR(i, N) {
        cin >> pos[i].x >> pos[i].y;
	}
    FR(i, N) {
        solve(i);
    }
    vector<int> ans;
    FR(j, M) {
        if (bad[j] == N) {
            ans.push_back(j+1);
        }
    }
    cout << ans.size() << '\n';
    for (int p :ans){
        cout << p << " ";
    }
	return 0;
}

Compilation message

fangorn.cpp: In function 'void solve(int)':
fangorn.cpp:84:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |         for (int i = 1; i < pt.size(); i++) {
      |                         ~~^~~~~~~~~~~
fangorn.cpp: In function 'int main()':
fangorn.cpp:109:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  109 |     freopen("input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Incorrect 2 ms 364 KB Output isn't correct
3 Incorrect 2 ms 364 KB Output isn't correct
4 Incorrect 3 ms 364 KB Output isn't correct
5 Incorrect 2 ms 364 KB Output isn't correct
6 Incorrect 3 ms 364 KB Output isn't correct
7 Correct 2 ms 364 KB Output is correct
8 Incorrect 2 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Incorrect 2 ms 364 KB Output isn't correct
3 Incorrect 2 ms 364 KB Output isn't correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Incorrect 3 ms 364 KB Output isn't correct
8 Incorrect 2 ms 364 KB Output isn't correct
9 Incorrect 2 ms 364 KB Output isn't correct
10 Incorrect 2 ms 364 KB Output isn't correct
11 Incorrect 2 ms 364 KB Output isn't correct
12 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -